제출 #405429

#제출 시각아이디문제언어결과실행 시간메모리
405429cgiosyLinear Garden (IOI08_linear_garden)C11
100 / 100
6 ms1244 KiB
main() { int N, M, X=0, Y=1; scanf("%d%d ", &N, &M); char S[N+1]; gets(S); 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", (X+Y%M+M)%M); }

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

linear_garden.c:1:1: warning: return type defaults to 'int' [-Wimplicit-int]
    1 | main() {
      | ^~~~
linear_garden.c: In function 'main':
linear_garden.c:3:2: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 |  scanf("%d%d ", &N, &M);
      |  ^~~~~
linear_garden.c:3:2: warning: incompatible implicit declaration of built-in function 'scanf'
linear_garden.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | main() {
linear_garden.c:5:2: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration]
    5 |  gets(S);
      |  ^~~~
linear_garden.c:7:10: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
    7 |   X<<=N-i-1&1;
      |       ~~~^~
linear_garden.c:10:31: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   10 |    if(t==l && r-l<2) X+=2+(N-i-1&1), Y--;
      |                            ~~~^~
linear_garden.c:15:2: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   15 |  printf("%d", (X+Y%M+M)%M);
      |  ^~~~~~
linear_garden.c:15:2: warning: incompatible implicit declaration of built-in function 'printf'
linear_garden.c:15:2: note: include '<stdio.h>' or provide a declaration of 'printf'
/usr/bin/ld: /tmp/ccY6jFNe.o: in function `main':
linear_garden.c:(.text.startup+0x83): warning: the `gets' function is dangerous and should not be used.
#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...