Submission #1051556

# Submission time Handle Problem Language Result Execution time Memory
1051556 2024-08-10T08:04:28 Z happy_node Crossing (JOI21_crossing) C++17
26 / 100
7000 ms 5948 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

mt19937 rng(time(0));

string JOI="JOI";

string merge(string a, string b) {
        string c="";
        for(int i=0;i<a.size();i++) {
                if(a[i]==b[i]) c+=a[i];
                else {
                        if(a[i]!='J' && b[i]!='J') c+='J';
                        if(a[i]!='O' && b[i]!='O') c+='O';
                        if(a[i]!='I' && b[i]!='I') c+='I';
                }
        }
        return c;
}

int main() {
        cin.tie(0); ios_base::sync_with_stdio(0);

        int N;
        cin>>N;

        string sa, sb, sc;
        cin>>sa>>sb>>sc;

        vector<string> v;
        set<string> st;

        if(!st.count(sa)) {
                v.push_back(sa);
                st.insert(sa);
        }
        if(!st.count(sb)) {
                v.push_back(sb);
                st.insert(sb);
        }
        if(!st.count(sc)) {
                v.push_back(sc);
                st.insert(sc);
        }

        while(true) {
                bool fnd=0;
                for(int i=0;i<v.size();i++) {
                        for(int j=i+1;j<v.size();j++) {
                                string c=merge(v[i],v[j]);
                                if(!st.count(c)) {
                                        fnd=true;
                                        v.push_back(c);
                                        st.insert(c);
                                }
                        }
                }
                if(!fnd) break;
        }

        int Q;
        cin>>Q;

        string S;
        cin>>S;

        cout<<(st.count(S)?"Yes":"No")<<'\n';

        for(int i=0;i<Q;i++) {
                int l,r; char c;
                cin>>l>>r>>c;
                l--,r--;
                for(int j=l;j<=r;j++) S[j]=c;
                cout<<(st.count(S)?"Yes":"No")<<'\n';
        }
}       

Compilation message

Main.cpp: In function 'std::string merge(std::string, std::string)':
Main.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for(int i=0;i<a.size();i++) {
      |                     ~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:50:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |                 for(int i=0;i<v.size();i++) {
      |                             ~^~~~~~~~~
Main.cpp:51:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |                         for(int j=i+1;j<v.size();j++) {
      |                                       ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2384 KB Output is correct
2 Correct 24 ms 2392 KB Output is correct
3 Correct 34 ms 2388 KB Output is correct
4 Correct 23 ms 2388 KB Output is correct
5 Correct 23 ms 2392 KB Output is correct
6 Correct 30 ms 2244 KB Output is correct
7 Correct 23 ms 2488 KB Output is correct
8 Correct 24 ms 2516 KB Output is correct
9 Correct 24 ms 2396 KB Output is correct
10 Correct 24 ms 2456 KB Output is correct
11 Correct 24 ms 2396 KB Output is correct
12 Correct 28 ms 2388 KB Output is correct
13 Correct 24 ms 2384 KB Output is correct
14 Correct 24 ms 2392 KB Output is correct
15 Correct 24 ms 2396 KB Output is correct
16 Correct 24 ms 2464 KB Output is correct
17 Correct 24 ms 2392 KB Output is correct
18 Correct 34 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2384 KB Output is correct
2 Correct 24 ms 2392 KB Output is correct
3 Correct 34 ms 2388 KB Output is correct
4 Correct 23 ms 2388 KB Output is correct
5 Correct 23 ms 2392 KB Output is correct
6 Correct 30 ms 2244 KB Output is correct
7 Correct 23 ms 2488 KB Output is correct
8 Correct 24 ms 2516 KB Output is correct
9 Correct 24 ms 2396 KB Output is correct
10 Correct 24 ms 2456 KB Output is correct
11 Correct 24 ms 2396 KB Output is correct
12 Correct 28 ms 2388 KB Output is correct
13 Correct 24 ms 2384 KB Output is correct
14 Correct 24 ms 2392 KB Output is correct
15 Correct 24 ms 2396 KB Output is correct
16 Correct 24 ms 2464 KB Output is correct
17 Correct 24 ms 2392 KB Output is correct
18 Correct 34 ms 2392 KB Output is correct
19 Correct 3590 ms 5948 KB Output is correct
20 Execution timed out 7065 ms 3544 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2384 KB Output is correct
2 Correct 24 ms 2392 KB Output is correct
3 Correct 34 ms 2388 KB Output is correct
4 Correct 23 ms 2388 KB Output is correct
5 Correct 23 ms 2392 KB Output is correct
6 Correct 30 ms 2244 KB Output is correct
7 Correct 23 ms 2488 KB Output is correct
8 Correct 24 ms 2516 KB Output is correct
9 Correct 24 ms 2396 KB Output is correct
10 Correct 24 ms 2456 KB Output is correct
11 Correct 24 ms 2396 KB Output is correct
12 Correct 28 ms 2388 KB Output is correct
13 Correct 24 ms 2384 KB Output is correct
14 Correct 24 ms 2392 KB Output is correct
15 Correct 24 ms 2396 KB Output is correct
16 Correct 24 ms 2464 KB Output is correct
17 Correct 24 ms 2392 KB Output is correct
18 Correct 34 ms 2392 KB Output is correct
19 Correct 25 ms 2388 KB Output is correct
20 Correct 36 ms 2388 KB Output is correct
21 Correct 26 ms 2528 KB Output is correct
22 Correct 23 ms 2648 KB Output is correct
23 Correct 25 ms 2396 KB Output is correct
24 Correct 24 ms 2392 KB Output is correct
25 Correct 26 ms 2388 KB Output is correct
26 Correct 23 ms 2392 KB Output is correct
27 Correct 25 ms 2384 KB Output is correct
28 Correct 23 ms 2140 KB Output is correct
29 Correct 25 ms 2392 KB Output is correct
30 Correct 23 ms 2392 KB Output is correct
31 Correct 31 ms 2568 KB Output is correct
32 Correct 30 ms 2504 KB Output is correct
33 Correct 26 ms 2384 KB Output is correct
34 Correct 24 ms 2396 KB Output is correct
35 Correct 29 ms 2392 KB Output is correct
36 Correct 26 ms 2364 KB Output is correct
37 Correct 27 ms 2436 KB Output is correct
38 Correct 26 ms 2388 KB Output is correct
39 Correct 27 ms 2388 KB Output is correct
40 Correct 26 ms 2388 KB Output is correct
41 Correct 27 ms 2388 KB Output is correct
42 Correct 25 ms 2388 KB Output is correct
43 Correct 36 ms 2392 KB Output is correct
44 Correct 26 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2384 KB Output is correct
2 Correct 24 ms 2392 KB Output is correct
3 Correct 34 ms 2388 KB Output is correct
4 Correct 23 ms 2388 KB Output is correct
5 Correct 23 ms 2392 KB Output is correct
6 Correct 30 ms 2244 KB Output is correct
7 Correct 23 ms 2488 KB Output is correct
8 Correct 24 ms 2516 KB Output is correct
9 Correct 24 ms 2396 KB Output is correct
10 Correct 24 ms 2456 KB Output is correct
11 Correct 24 ms 2396 KB Output is correct
12 Correct 28 ms 2388 KB Output is correct
13 Correct 24 ms 2384 KB Output is correct
14 Correct 24 ms 2392 KB Output is correct
15 Correct 24 ms 2396 KB Output is correct
16 Correct 24 ms 2464 KB Output is correct
17 Correct 24 ms 2392 KB Output is correct
18 Correct 34 ms 2392 KB Output is correct
19 Correct 3590 ms 5948 KB Output is correct
20 Execution timed out 7065 ms 3544 KB Time limit exceeded
21 Halted 0 ms 0 KB -