Submission #419975

# Submission time Handle Problem Language Result Execution time Memory
419975 2021-06-07T20:31:21 Z davi_bart Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 2352 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fi first
#define se second
#define ld long double
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N,Q;
set<string> k;
string a,b,c;
string t;
vector<bool> ok;
void solve(){
    if(k.count(t))cout<<"Yes\n";
    else cout<<"No\n";
}
string cross(string x,string y){
    string ans="";
    vector<char> s={'I','J','O'};
    for(int i=0;i<x.size();i++){
        if(x[i]==y[i])ans+=x[i];
        else{
            for(auto h:s)if(x[i]!=h && y[i]!=h)ans+=h;
        }
    }
    return ans;
}
void calc(){
    while(1){
        bool ok=0;
        for(auto x:k){
            for(auto y:k){
                string h=cross(x,y);
                if(k.count(h))continue;
                ok=1;
                k.insert(h);
            }
        }
        if(!ok)break;
    }
}
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);
    cin>>N>>a>>b>>c>>Q>>t;
    k.insert(a);k.insert(b);k.insert(c);
    calc();
    assert(k.size()<10);
    solve();
    for(int i=0;i<Q;i++){
        int x,y;
        char z;
        cin>>x>>y>>z;
        x--;y--;
        for(int j=x;j<=y;j++)t[j]=z;
        solve();

    }


}

Compilation message

Main.cpp: In function 'std::string cross(std::string, std::string)':
Main.cpp:23:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 51 ms 828 KB Output is correct
2 Correct 59 ms 904 KB Output is correct
3 Correct 95 ms 1004 KB Output is correct
4 Correct 58 ms 776 KB Output is correct
5 Correct 55 ms 760 KB Output is correct
6 Correct 66 ms 816 KB Output is correct
7 Correct 54 ms 864 KB Output is correct
8 Correct 57 ms 896 KB Output is correct
9 Correct 60 ms 848 KB Output is correct
10 Correct 55 ms 836 KB Output is correct
11 Correct 66 ms 836 KB Output is correct
12 Correct 56 ms 880 KB Output is correct
13 Correct 55 ms 824 KB Output is correct
14 Correct 55 ms 860 KB Output is correct
15 Correct 55 ms 832 KB Output is correct
16 Correct 57 ms 796 KB Output is correct
17 Correct 54 ms 836 KB Output is correct
18 Correct 95 ms 880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 828 KB Output is correct
2 Correct 59 ms 904 KB Output is correct
3 Correct 95 ms 1004 KB Output is correct
4 Correct 58 ms 776 KB Output is correct
5 Correct 55 ms 760 KB Output is correct
6 Correct 66 ms 816 KB Output is correct
7 Correct 54 ms 864 KB Output is correct
8 Correct 57 ms 896 KB Output is correct
9 Correct 60 ms 848 KB Output is correct
10 Correct 55 ms 836 KB Output is correct
11 Correct 66 ms 836 KB Output is correct
12 Correct 56 ms 880 KB Output is correct
13 Correct 55 ms 824 KB Output is correct
14 Correct 55 ms 860 KB Output is correct
15 Correct 55 ms 832 KB Output is correct
16 Correct 57 ms 796 KB Output is correct
17 Correct 54 ms 836 KB Output is correct
18 Correct 95 ms 880 KB Output is correct
19 Execution timed out 7087 ms 2352 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 828 KB Output is correct
2 Correct 59 ms 904 KB Output is correct
3 Correct 95 ms 1004 KB Output is correct
4 Correct 58 ms 776 KB Output is correct
5 Correct 55 ms 760 KB Output is correct
6 Correct 66 ms 816 KB Output is correct
7 Correct 54 ms 864 KB Output is correct
8 Correct 57 ms 896 KB Output is correct
9 Correct 60 ms 848 KB Output is correct
10 Correct 55 ms 836 KB Output is correct
11 Correct 66 ms 836 KB Output is correct
12 Correct 56 ms 880 KB Output is correct
13 Correct 55 ms 824 KB Output is correct
14 Correct 55 ms 860 KB Output is correct
15 Correct 55 ms 832 KB Output is correct
16 Correct 57 ms 796 KB Output is correct
17 Correct 54 ms 836 KB Output is correct
18 Correct 95 ms 880 KB Output is correct
19 Correct 60 ms 820 KB Output is correct
20 Correct 97 ms 892 KB Output is correct
21 Correct 58 ms 888 KB Output is correct
22 Correct 51 ms 788 KB Output is correct
23 Correct 57 ms 796 KB Output is correct
24 Correct 54 ms 812 KB Output is correct
25 Correct 61 ms 828 KB Output is correct
26 Correct 52 ms 792 KB Output is correct
27 Correct 66 ms 836 KB Output is correct
28 Correct 54 ms 836 KB Output is correct
29 Correct 57 ms 776 KB Output is correct
30 Correct 53 ms 836 KB Output is correct
31 Correct 62 ms 840 KB Output is correct
32 Correct 59 ms 900 KB Output is correct
33 Correct 61 ms 892 KB Output is correct
34 Correct 54 ms 852 KB Output is correct
35 Correct 62 ms 868 KB Output is correct
36 Correct 59 ms 832 KB Output is correct
37 Correct 60 ms 820 KB Output is correct
38 Correct 59 ms 876 KB Output is correct
39 Correct 60 ms 852 KB Output is correct
40 Correct 58 ms 856 KB Output is correct
41 Correct 73 ms 836 KB Output is correct
42 Correct 60 ms 892 KB Output is correct
43 Correct 56 ms 880 KB Output is correct
44 Correct 59 ms 836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 828 KB Output is correct
2 Correct 59 ms 904 KB Output is correct
3 Correct 95 ms 1004 KB Output is correct
4 Correct 58 ms 776 KB Output is correct
5 Correct 55 ms 760 KB Output is correct
6 Correct 66 ms 816 KB Output is correct
7 Correct 54 ms 864 KB Output is correct
8 Correct 57 ms 896 KB Output is correct
9 Correct 60 ms 848 KB Output is correct
10 Correct 55 ms 836 KB Output is correct
11 Correct 66 ms 836 KB Output is correct
12 Correct 56 ms 880 KB Output is correct
13 Correct 55 ms 824 KB Output is correct
14 Correct 55 ms 860 KB Output is correct
15 Correct 55 ms 832 KB Output is correct
16 Correct 57 ms 796 KB Output is correct
17 Correct 54 ms 836 KB Output is correct
18 Correct 95 ms 880 KB Output is correct
19 Execution timed out 7087 ms 2352 KB Time limit exceeded
20 Halted 0 ms 0 KB -