제출 #405419

#제출 시각아이디문제언어결과실행 시간메모리
405419cgiosyLinear Garden (IOI08_linear_garden)C++17
100 / 100
7 ms2268 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int N, M; cin>>N>>M; char S[N+1]; cin>>S; int X=0, Y=0, Z=1; for(int i=0, t=0, l=0, r=0; i<N; i++) { X<<=N-i-1&1; X=X>=M ? X-M : X; Y<<=N-i-1&1; Y=Y>=M ? Y-M : Y; if(S[i]=='P') { if(t==l && r-l<2) X+=2+(N-i-1&1), Z--; else if(t==l) X++; else if(t<l+2) Y++; l=min(l, --t); } else r=max(r, ++t); } cout<<(X+Y+Z)%M<<'\n'; }

컴파일 시 표준 에러 (stderr) 메시지

linear_garden.cpp: In function 'int main()':
linear_garden.cpp:12:10: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   12 |   X<<=N-i-1&1;
      |       ~~~^~
linear_garden.cpp:14:10: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   14 |   Y<<=N-i-1&1;
      |       ~~~^~
linear_garden.cpp:17:31: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   17 |    if(t==l && r-l<2) X+=2+(N-i-1&1), Z--;
      |                            ~~~^~
#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...