Submission #231999

#TimeUsernameProblemLanguageResultExecution timeMemory
231999Dremix10Linear Garden (IOI08_linear_garden)C++17
36 / 100
1592 ms65540 KiB
#include <bits/stdc++.h> using namespace std; int n,m; string s; int ans; int cnt=0; void solve(string a){ //int i=a.size()-1; //cnt++; int i; // cout<<a<<" "<<cnt<<endl; if(a.size()==n){ cnt++; cnt%=m; //cout<<cnt<<" "<<a<<endl; if(a==s) ans=cnt; return; } if(a.size()<2){ solve(a+'1'); solve(a+'2'); return; } int o=0,t=0; bool f=true,s=true; int k=a.size()-1; for(i=k;i>=0;i--){ if(a[i]=='1') o++; else t++; if(abs(o+1-t)>2) f=false; if(abs(t+1-o)>2) s=false; } if(f) solve(a+'1'); if(s) solve(a+'2'); } int main (){ cin>>n>>m>>s; int i; for(i=0;i<n;i++) if(s[i]=='L') s[i]='1'; else s[i]='2'; solve(""); cout<<ans; }

Compilation message (stderr)

linear_garden.cpp: In function 'void solve(std::__cxx11::string)':
linear_garden.cpp:15:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(a.size()==n){
        ~~~~~~~~^~~
#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...
#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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...