Submission #862040

#TimeUsernameProblemLanguageResultExecution timeMemory
862040Aiperiiiparentrises (BOI18_parentrises)C++14
50 / 100
130 ms5192 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 signed main(){ int p,t; cin>>p>>t; if(p==1){ while(t--){ string s,x=""; cin>>s; stack <int> st; for(int i=0;i<s.size();i++){ x+='.'; } for(int i=0;i<s.size();i++){ if(s[i]=='(')st.push(i); else{ if(st.size()!=0){ x[st.top()]='R'; x[i]='R'; st.pop(); } } } while(st.size()!=0)st.pop(); for(int i=0;i<s.size();i++){ if(s[i]=='(' && x[i]=='.')st.push(i); else if(s[i]==')'){ if(st.size()!=0){ x[st.top()]='B'; x[i]='G'; st.pop(); } } } while(st.size()!=0)st.pop(); for(int i=s.size()-1;i>=0;i--){ if(s[i]==')' && x[i]=='.')st.push(i); else if(s[i]=='(' && x[i]=='R'){ if(st.size()!=0){ x[st.top()]='B'; x[i]='G'; st.pop(); } } } bool flag=true; for(int i=0;i<x.size();i++){ if(x[i]=='.')flag=false; } if(flag)cout<<x<<"\n"; else cout<<"impossible\n"; } } }

Compilation message (stderr)

parentrises.cpp: In function 'int main()':
parentrises.cpp:15:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |             for(int i=0;i<s.size();i++){
      |                         ~^~~~~~~~~
parentrises.cpp:18:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |             for(int i=0;i<s.size();i++){
      |                         ~^~~~~~~~~
parentrises.cpp:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for(int i=0;i<s.size();i++){
      |                         ~^~~~~~~~~
parentrises.cpp:51:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             for(int i=0;i<x.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...