Submission #95190

#TimeUsernameProblemLanguageResultExecution timeMemory
95190easruiLinear Garden (IOI08_linear_garden)C++14
100 / 100
17 ms2452 KiB
#include <bits/stdc++.h> using namespace std; int N,M,X,Y,Z,u,d,tmpx; int main() { ios_base::sync_with_stdio(0),cin.tie(0); //freopen("input.txt","r",stdin); string S; cin >> N >> M >> S; for(int i=0; i<S.size(); i++) { tmpx = X; X = 2*Y + Z; Y = tmpx; if(S[i]=='P' && u!=2) { if(u==1) X++; else if(d==-2) Y++; else Z++; } if(S[i]=='L'){ u = max(u+1,1); d = d+1; } else{ u = u-1; d = min(d-1,-1); } X %= M; Y %= M; Z %= M; //cout << X << Y << Z << u << d << '\n'; } cout << (X+Y+Z+1)%M; }

Compilation message (stderr)

linear_garden.cpp: In function 'int main()':
linear_garden.cpp:10:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     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...
#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...