제출 #54586

#제출 시각아이디문제언어결과실행 시간메모리
54586khsoo01Miners (IOI07_miners)C++11
100 / 100
351 ms700 KiB
#include<bits/stdc++.h> using namespace std; const int N = 100005, inf = 1e9; int n, dt[2][4][4][4][4]; char a[N]; int val (int A, int B, int C) { return ((A == 1) | (B == 1) | (C == 1)) + ((A == 2) | (B == 2) | (C == 2)) + ((A == 3) | (B == 3) | (C == 3)); } int main() { scanf("%d%s",&n,a+1); for(int j=0;j<256;j++) { int A = j/64, B = j/16%4, C = j/4%4, D = j%4; dt[0][A][B][C][D] = -inf; } dt[0][0][0][0][0] = 0; for(int i=1;i<=n;i++) { int E = (a[i] == 'M')*1 + (a[i] == 'B')*2 + (a[i] == 'F')*3; for(int j=0;j<256;j++) { int A = j/64, B = j/16%4, C = j/4%4, D = j%4; dt[i%2][A][B][C][D] = -inf; } for(int j=0;j<256;j++) { int A = j/64, B = j/16%4, C = j/4%4, D = j%4, P = dt[1-i%2][A][B][C][D]; dt[i%2][B][E][C][D] = max(dt[i%2][B][E][C][D], P + val(A, B, E)); dt[i%2][A][B][D][E] = max(dt[i%2][A][B][D][E], P + val(C, D, E)); } } int ans = 0; for(int j=0;j<256;j++) { int A = j/64, B = j/16%4, C = j/4%4, D = j%4; ans = max(ans, dt[n%2][A][B][C][D]); } printf("%d\n",ans); }

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

miners.cpp: In function 'int main()':
miners.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%s",&n,a+1);
  ~~~~~^~~~~~~~~~~~~~~
#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...