제출 #1099507

#제출 시각아이디문제언어결과실행 시간메모리
1099507modwweGrowing Vegetable is Fun 3 (JOI19_ho_t3)C++17
100 / 100
418 ms4188 KiB
#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC optimize("conserve-stack") #include<bits/stdc++.h> //#define int long long #define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar inline int scan() { char c = getchar_unlocked(); int x = 0; while (c < '0' || c > '9') { c = getchar_unlocked(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + c - '0'; c = getchar_unlocked(); } return x; } void phongbeo(); const int inf = 1e9; const int mod2 = 1e9 + 7; const int mod1 = 998244353; struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a, b, c; }; struct id { int a, b, c, d; }; struct ie { int a, b, c, d, e; }; int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, l, r, mid, l2, r2, center; int i, s10, s12,k1,k2,k3,s11,t,lim,w; int kk; int el = 19; main() { if(fopen(task".inp","r")) { fin(task); fou(task); } NHP /// cin>>s1; ///modwwe phongbeo(); // checktime } string s; int dp[2][401][401][3];///dp(0,1) i j f1 f2 /// -> i la cot G /// ->j la cot Y int a[401][3]; int gf[3]; int p1[3]; int p2[3]; vector<int> v[3]; void phongbeo() { cin>>n; cin>>s; s=" "+s; p1[0]=0; p1[1]=1; p1[2]=0; p2[0]=0; p2[1]=0; p2[2]=1; dp[0][0][0][0]=dp[0][0][0][1]=dp[0][0][0][2]=0; for(int i=1; i<=n; i++) { if(s[i]=='R') s2=0; else if(s[i]=='G')s2=1; else s2=2; a[i][s2]++; v[s2].pb(i); for(int f=0; f<=2; f++) a[i][f]+=a[i-1][f]; } for(int i=1; i<=n; i++) { for(int j=0; j<=i; j++) for(int z=0; z+j<=i; z++) for(int f=0; f<=2; f++) dp[i&1][j][z][f]=inf; for(int j=0; j<=min(i-1,a[n][1]); j++) for(int z=0; z<=min(i-1-j,a[n][2]); z++) for(int f=0; f<=2; f++) for(int f2=0; f2<=2; f2++) { if(f==f2) continue; s3=(i-1-j-z); if(s3>a[n][0]) break; s4=j; s5=z; gf[0]=s3; gf[1]=s4; gf[2]=s5; gf[f2]++; if(gf[f2]>a[n][f2]) continue; s8=v[f2][gf[f2]-1]; s9=0; for(int tt=0; tt<=2; tt++) if(tt!=f2) { s7=lower_bound(v[tt].begin(),v[tt].end(),s8)-v[tt].begin(); s9+=max(0,gf[tt]-s7); } s10=s9+s8; s9=s10-i; dp[i&1][j+p1[f2]][z+p2[f2]][f2]=min(dp[i&1][j+p1[f2]][z+p2[f2]][f2],dp[(i-1)&1][j][z][f]+s9); } } if(min({dp[n&1][a[n][1]][a[n][2]][0],dp[n&1][a[n][1]][a[n][2]][1],dp[n&1][a[n][1]][a[n][2]][2]})==inf) cout<<-1; else cout<<min({dp[n&1][a[n][1]][a[n][2]][0],dp[n&1][a[n][1]][a[n][2]][1],dp[n&1][a[n][1]][a[n][2]][2]}); } //1 3 0 1 0

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

joi2019_ho_t3.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main()
      | ^~~~
joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:73:9: note: in expansion of macro 'fin'
   73 |         fin(task);
      |         ^~~
joi2019_ho_t3.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
joi2019_ho_t3.cpp:74:9: note: in expansion of macro 'fou'
   74 |         fou(task);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...