Submission #861839

#TimeUsernameProblemLanguageResultExecution timeMemory
861839Aiperiiiparentrises (BOI18_parentrises)C++17
5 / 100
685 ms262144 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(),x.end() #define ff first #define ss second bool ok(string s,string x){ int cnt=0; for(int i=0;i<s.size();i++){ if(s[i]=='G' && x[i]=='('){ cnt++; } else if(s[i]=='B' && x[i]=='('){ cnt++; } else if(s[i]=='B' && x[i]==')'){ cnt--; if(cnt<0)return false; } else if(s[i]=='G' && x[i]==')'){ cnt--; if(cnt<0)return false; } } if(cnt!=0) return false; cnt=0; for(int i=0;i<s.size();i++){ if(s[i]=='G' && x[i]=='('){ cnt++; } else if(s[i]=='R' && x[i]=='('){ cnt++; } else if(s[i]=='R' && x[i]==')'){ cnt--; if(cnt<0)return false; } else if(s[i]=='G' && x[i]==')'){ cnt--; if(cnt<0)return false; } } if(cnt!=0) return false; return true; } signed main(){ int p,t; cin>>p>>t; if(p==1){ while(t--){ string s; cin>>s; string ans="impossible"; queue <string> q; q.push(""); while(!q.empty()){ string v=q.front(); q.pop(); if(v.size()==s.size()){ if(ok(v,s)){ ans=v; break; } } else{ q.push(v+'R'); q.push(v+'B'); q.push(v+'G'); } } cout<<ans<<"\n"; } } }

Compilation message (stderr)

parentrises.cpp: In function 'bool ok(std::string, std::string)':
parentrises.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
parentrises.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...