제출 #405437

#제출 시각아이디문제언어결과실행 시간메모리
405437cgiosyLinear Garden (IOI08_linear_garden)C11
100 / 100
5 ms1228 KiB
#include <stdio.h> int main() { int N, M, X=0, Y=1; scanf("%d%d\n", &N, &M); char S[N]; fread(S, 1, N, stdin); for(int i=0, t=0, l=0, r=0; i<N; i++) { X<<=N-i-1&1; X=X>=M ? X-M : X; if(S[i]=='P') { if(t==l && r-l<2) X+=2+(N-i-1&1), Y--; else if(t<l+2) X++; if(l>--t) l=t; } else if(r<++t) r=t; } printf("%d\n", (X+Y%M+M)%M); }

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

linear_garden.c: In function 'main':
linear_garden.c:8:10: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
    8 |   X<<=N-i-1&1;
      |       ~~~^~
linear_garden.c:11:31: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   11 |    if(t==l && r-l<2) X+=2+(N-i-1&1), Y--;
      |                            ~~~^~
linear_garden.c:4:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 |  scanf("%d%d\n", &N, &M);
      |  ^~~~~~~~~~~~~~~~~~~~~~~
linear_garden.c:6:2: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  fread(S, 1, N, stdin);
      |  ^~~~~~~~~~~~~~~~~~~~~
#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...