이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |