Submission #1051556

#TimeUsernameProblemLanguageResultExecution timeMemory
1051556happy_nodeCrossing (JOI21_crossing)C++17
26 / 100
7065 ms5948 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...