# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
432353 | juggernaut | Miners (IOI07_miners) | C++17 | 1583 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
typedef long long ll;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef IOI2021SG
#define printl(args...)printf(args)
#else
#define printl(args...)((void)0)
#endif
char s[100005];
int dp[2][64][64];
int cost[64];
int mx;
void add(char ch){
int id;
if(ch=='M')id=1;
if(ch=='B')id=2;
if(ch=='F')id=3;
for(int i=0;i<64;i++)
for(int j=0;j<64;j++){
int x=i;
x&=15;
x<<=2;
x+=id;
umax(dp[1][x][j],dp[0][i][j]+cost[x]);
umax(mx,dp[1][x][j]);
x=j;
x&=15;
x<<=2;
x+=id;
umax(dp[1][i][x],dp[0][i][j]+cost[x]);
umax(mx,dp[1][i][x]);
}
for(int i=0;i<64;i++)
for(int j=0;j<64;j++){
dp[0][i][j]=dp[1][i][j];
dp[1][i][j]=-1e9;
}
}
int main(){
for(int x=0;x<2;x++)
for(int i=0;i<64;i++)
for(int j=0;j<64;j++)dp[x][i][j]=-1e9;
dp[0][0][0]=0;
for(int i=0;i<64;i++){
int tmp=i;
int x=tmp&3;
tmp>>=2;
int y=tmp&3;
tmp>>=2;
int z=tmp&3;
set<int>st;
st.insert(x);
st.insert(y);
st.insert(z);
st.erase(0);
cost[i]=st.size();
}
int n;
scanf("%d",&n);
scanf("%s",&s);
for(int i=0;i<n;i++)add(s[i]);
printf("%d",mx);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |