이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define INF 1e+18
#define int long long
using namespace std;
int knd(int a,int b,int c){
int cnt[4] = {};
if(!cnt[a]) cnt[a]++;
if(!cnt[b]) cnt[b]++;
if(!cnt[c]) cnt[c]++;
return cnt[1] + cnt[2] + cnt[3];
}
signed main(){
int n,dp[2][4][4][4][4],now = 0,nxt = 1,ma = 0;
string s;
cin >> n >> s;
for(int i = 0;i < 4;i++){
for(int j = 0;j < 4;j++){
for(int k = 0;k < 4;k++){
for(int l = 0;l < 4;l++){
dp[0][i][j][k][l] = -INF;
dp[1][i][j][k][l] = -INF;
}
}
}
}
dp[0][0][0][0][0] = 0;
for(int i = 0;i < n;i++){
for(int j = 0;j < 4;j++){
for(int k = 0;k < 4;k++){
for(int l = 0;l < 4;l++){
for(int m = 0;m < 4;m++){
int num,add = 0;
if(s[i] == 'M') num = 1;
else if(s[i] == 'B') num = 2;
else num = 3;
dp[nxt][k][num][l][m] = max(dp[nxt][k][num][l][m],dp[now][j][k][l][m] + knd(j,k,num));
dp[nxt][j][k][m][num] = max(dp[nxt][j][k][m][num],dp[now][j][k][l][m] + knd(l,m,num));
}
}
}
}
swap(now,nxt);
}
for(int i = 0;i < 4;i++){
for(int j = 0;j < 4;j++){
for(int k = 0;k < 4;k++){
for(int l = 0;l < 4;l++) ma = max(ma,dp[now][i][j][k][l]);
}
}
}
cout << ma << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
miners.cpp: In function 'int main()':
miners.cpp:34:15: warning: unused variable 'add' [-Wunused-variable]
int num,add = 0;
^~~
# | 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... |