Submission #620016

# Submission time Handle Problem Language Result Execution time Memory
620016 2022-08-02T18:48:53 Z APROHACK Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 5656 KB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
ll n, q;
string a, b, c, x;
vector<string>strings;
set<string>st;
void input(){
    cin>>n;
    cin>>a>>b>>c;
    strings.pb(a);
    strings.pb(b);
    strings.pb(c);
    st.insert(a);
    st.insert(b);
    st.insert(c);
}
bool join(int a, int b){
    string nueva="";
    //cout << a << " " << b << endl;
    for(int i = 0 ; i < n ; i++){
        if(strings[a][i]==strings[b][i]){
            nueva+=strings[a][i];
        }else {
            if((strings[a][i]=='J' && strings[b][i]=='O' )|| (strings[b][i]=='J' && strings[a][i]=='O'))nueva+="I";
            else if((strings[a][i]=='I' && strings[b][i]=='O') || (strings[b][i]=='I' && strings[a][i]=='O'))nueva+="J";
            else if((strings[a][i]=='I' && strings[b][i]=='J') || (strings[b][i]=='I' && strings[a][i]=='J'))nueva+="O";
        }
    }
    if(st.find(nueva)==st.end()){
        //cout << nueva << endl;
        st.insert(nueva);
        strings.pb(nueva);
    }else{
        return false;
    }
    return true;
}
void calculateString(){
    bool ans = true;
    while(ans){
        ans = false;
        int gen = strings.size();
        for(int i = 0 ; i < gen-1; i++){
            for(int j = i+1 ; j < gen ; j++){
                if(join(i, j))ans = true;
            }
        }
    }
}
void querys(){
    cin>>q;
    cin>>x;
    if(st.find(x)!=st.end())cout<<"Yes\n";
    else cout << "No\n";
    int l, r;
    char c;
    for(int i = 0 ;i  < q ; i++){
        cin>>l>>r>>c;
        for(int i = l-1 ; i <= r-1 ; i++){
            x[i]=c;
        }
        //cout << "ask "<<x<<endl;
        if(st.find(x)!=st.end())cout<<"Yes\n";
        else cout << "No\n";
    }
}
int main(){
    input();
    calculateString();
    querys();
}
# Verdict Execution time Memory Grader output
1 Correct 316 ms 836 KB Output is correct
2 Correct 329 ms 2380 KB Output is correct
3 Correct 361 ms 2240 KB Output is correct
4 Correct 357 ms 2304 KB Output is correct
5 Correct 317 ms 2232 KB Output is correct
6 Correct 314 ms 2268 KB Output is correct
7 Correct 314 ms 2264 KB Output is correct
8 Correct 346 ms 2304 KB Output is correct
9 Correct 331 ms 2328 KB Output is correct
10 Correct 366 ms 2392 KB Output is correct
11 Correct 326 ms 2416 KB Output is correct
12 Correct 332 ms 2388 KB Output is correct
13 Correct 323 ms 2296 KB Output is correct
14 Correct 383 ms 2476 KB Output is correct
15 Correct 332 ms 2356 KB Output is correct
16 Correct 332 ms 2392 KB Output is correct
17 Correct 338 ms 2388 KB Output is correct
18 Correct 370 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 316 ms 836 KB Output is correct
2 Correct 329 ms 2380 KB Output is correct
3 Correct 361 ms 2240 KB Output is correct
4 Correct 357 ms 2304 KB Output is correct
5 Correct 317 ms 2232 KB Output is correct
6 Correct 314 ms 2268 KB Output is correct
7 Correct 314 ms 2264 KB Output is correct
8 Correct 346 ms 2304 KB Output is correct
9 Correct 331 ms 2328 KB Output is correct
10 Correct 366 ms 2392 KB Output is correct
11 Correct 326 ms 2416 KB Output is correct
12 Correct 332 ms 2388 KB Output is correct
13 Correct 323 ms 2296 KB Output is correct
14 Correct 383 ms 2476 KB Output is correct
15 Correct 332 ms 2356 KB Output is correct
16 Correct 332 ms 2392 KB Output is correct
17 Correct 338 ms 2388 KB Output is correct
18 Correct 370 ms 2292 KB Output is correct
19 Execution timed out 7049 ms 5656 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 316 ms 836 KB Output is correct
2 Correct 329 ms 2380 KB Output is correct
3 Correct 361 ms 2240 KB Output is correct
4 Correct 357 ms 2304 KB Output is correct
5 Correct 317 ms 2232 KB Output is correct
6 Correct 314 ms 2268 KB Output is correct
7 Correct 314 ms 2264 KB Output is correct
8 Correct 346 ms 2304 KB Output is correct
9 Correct 331 ms 2328 KB Output is correct
10 Correct 366 ms 2392 KB Output is correct
11 Correct 326 ms 2416 KB Output is correct
12 Correct 332 ms 2388 KB Output is correct
13 Correct 323 ms 2296 KB Output is correct
14 Correct 383 ms 2476 KB Output is correct
15 Correct 332 ms 2356 KB Output is correct
16 Correct 332 ms 2392 KB Output is correct
17 Correct 338 ms 2388 KB Output is correct
18 Correct 370 ms 2292 KB Output is correct
19 Correct 319 ms 2216 KB Output is correct
20 Correct 358 ms 2220 KB Output is correct
21 Correct 331 ms 2380 KB Output is correct
22 Correct 300 ms 2144 KB Output is correct
23 Correct 340 ms 2404 KB Output is correct
24 Correct 376 ms 2400 KB Output is correct
25 Correct 321 ms 2356 KB Output is correct
26 Correct 328 ms 2280 KB Output is correct
27 Correct 323 ms 2380 KB Output is correct
28 Correct 302 ms 2112 KB Output is correct
29 Correct 350 ms 2380 KB Output is correct
30 Correct 301 ms 2180 KB Output is correct
31 Correct 325 ms 2364 KB Output is correct
32 Correct 377 ms 2400 KB Output is correct
33 Correct 336 ms 2400 KB Output is correct
34 Correct 311 ms 2268 KB Output is correct
35 Correct 349 ms 2404 KB Output is correct
36 Correct 328 ms 2380 KB Output is correct
37 Correct 326 ms 2476 KB Output is correct
38 Correct 331 ms 2380 KB Output is correct
39 Correct 336 ms 2344 KB Output is correct
40 Correct 345 ms 2420 KB Output is correct
41 Correct 330 ms 2308 KB Output is correct
42 Correct 350 ms 2480 KB Output is correct
43 Correct 332 ms 2404 KB Output is correct
44 Correct 354 ms 2372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 316 ms 836 KB Output is correct
2 Correct 329 ms 2380 KB Output is correct
3 Correct 361 ms 2240 KB Output is correct
4 Correct 357 ms 2304 KB Output is correct
5 Correct 317 ms 2232 KB Output is correct
6 Correct 314 ms 2268 KB Output is correct
7 Correct 314 ms 2264 KB Output is correct
8 Correct 346 ms 2304 KB Output is correct
9 Correct 331 ms 2328 KB Output is correct
10 Correct 366 ms 2392 KB Output is correct
11 Correct 326 ms 2416 KB Output is correct
12 Correct 332 ms 2388 KB Output is correct
13 Correct 323 ms 2296 KB Output is correct
14 Correct 383 ms 2476 KB Output is correct
15 Correct 332 ms 2356 KB Output is correct
16 Correct 332 ms 2392 KB Output is correct
17 Correct 338 ms 2388 KB Output is correct
18 Correct 370 ms 2292 KB Output is correct
19 Execution timed out 7049 ms 5656 KB Time limit exceeded
20 Halted 0 ms 0 KB -