제출 #559849

#제출 시각아이디문제언어결과실행 시간메모리
559849_BodyLinear Garden (IOI08_linear_garden)Java
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define int long long using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r){ uniform_int_distribution<int> uid(l, r); return uid(rng); } string s; int N,M; int dp[2][2][5][5][5]; int DP() { for(int i=N;i>=0;i--) { for(int tight=0;tight<2;tight++) { for(int mn=0;mn<=2;mn++) { for(int mx=2;mx<=4;mx++) { if(mx-mn>2) continue; for(int where=mn;where<=mx;where++) { if(tight) { int &ret=dp[i&1][1][mn][mx][where]; ret=0; if(i==N){ ret=1; continue; } for(int d=0;d<=s[i]-'0';d++) { if(d==s[i]-'0') { if(d==0&&where-1>=0) ret+=dp[(i+1)&1][1][min(mn,where-1)][mx][where-1]; else if(d==1&&where+1<5) ret+=dp[(i+1)&1][1][mn][max(mx,where+1)][where+1]; } else { if(d==0&&where-1>=0) ret+=dp[(i+1)&1][0][min(mn,where-1)][mx][where-1]; else if(d==1&&where+1<5) ret+=dp[(i+1)&1][0][mn][max(mx,where+1)][where+1]; } ret=ret%M; } } else { int &ret=dp[i&1][0][mn][mx][where]; ret=0; if(i==N){ ret=1; continue; } for(int d=0;d<=1;d++) { if(d==s[i]-'0') { if(d==0&&where-1>=0) ret+=dp[(i+1)&1][0][min(mn,where-1)][mx][where-1]; else if(d==1&&where+1<5) ret+=dp[(i+1)&1][0][mn][max(mx,where+1)][where+1]; } else { if(d==0&&where-1>=0) ret+=dp[(i+1)&1][0][min(mn,where-1)][mx][where-1]; else if(d==1&&where+1<5) ret+=dp[(i+1)&1][0][mn][max(mx,where+1)][where+1]; } ret=ret%M; } } } } } } } return dp[0][1][2][2][2]; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("team.in","r",stdin); // freopen("team.out","w",stdout); int tt=1; // cin>>tt; int T=1; while(tt--) { cin>>N>>M; cin>>s; for(int i=0;i<N;i++) { if(s[i]=='L') s[i]='0'; else s[i]='1'; } cout<<DP()<<"\n"; //cout<<s<<"\n"; } } /*stolen stuff you should look for * int overflow, array bounds * special cases (n=1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */

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

linear_garden.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
linear_garden.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
        ^
linear_garden.java:2: error: illegal character: '#'
#define int long long
^
linear_garden.java:5: error: class, interface, or enum expected
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
^
linear_garden.java:7: error: class, interface, or enum expected
int rand(int l, int r){
^
linear_garden.java:9: error: class, interface, or enum expected
    return uid(rng);
    ^
linear_garden.java:10: error: class, interface, or enum expected
}
^
linear_garden.java:12: error: class, interface, or enum expected
int N,M;
^
linear_garden.java:13: error: class, interface, or enum expected
int dp[2][2][5][5][5];
^
linear_garden.java:14: error: class, interface, or enum expected
int DP() 
^
linear_garden.java:17: error: class, interface, or enum expected
for(int i=N;i>=0;i--)
            ^
linear_garden.java:17: error: class, interface, or enum expected
for(int i=N;i>=0;i--)
                 ^
linear_garden.java:19: error: class, interface, or enum expected
    for(int tight=0;tight<2;tight++)
                    ^
linear_garden.java:19: error: class, interface, or enum expected
    for(int tight=0;tight<2;tight++)
                            ^
linear_garden.java:21: error: class, interface, or enum expected
        for(int mn=0;mn<=2;mn++)
                     ^
linear_garden.java:21: error: class, interface, or enum expected
        for(int mn=0;mn<=2;mn++)
                           ^
linear_garden.java:23: error: class, interface, or enum expected
            for(int mx=2;mx<=4;mx++)
                         ^
linear_garden.java:23: error: class, interface, or enum expected
            for(int mx=2;mx<=4;mx++)
                               ^
linear_garden.java:27: error: class, interface, or enum expected
                for(int where=mn;where<=mx;where++)
                ^
linear_garden.java:27: error: class, interface, or enum expected
                for(int where=mn;where<=mx;where++)
                                 ^
linear_garden.java:27: error: class, interface, or enum expected
                for(int where=mn;where<=mx;where++)
                                           ^
linear_garden.java:32: error: class, interface, or enum expected
                        ret=0;
                        ^
linear_garden.java:33: error: class, interface, or enum expected
                     if(i==N){
                     ^
linear_garden.java:35: error: class, interface, or enum expected
                        continue;
                        ^
linear_garden.java:36: error: class, interface, or enum expected
                    }
                    ^
linear_garden.java:37: error: class, interface, or enum expected
                        for(int d=0;d<=s[i]-'0';d++)
                                    ^
linear_garden.java:37: error: class, interface, or enum expected
                        for(int d=0;d<=s[i]-'0';d++)
                                                ^
linear_garden.java:43: error: class, interface, or enum expected
                            else if(d==1&&where+1<5) ret+=dp[(i+1)&1][1][mn][max(mx,where+1)][where+1];
                            ^
linear_garden.java:44: error: class, interface, or enum expected
                            }
                            ^
linear_garden.java:48: error: class, interface, or enum expected
                            else if(d==1&&where+1<5) ret+=dp[(i+1)&1][0][mn][max(mx,where+1)][where+1];
                            ^
linear_garden.java:49: error: class, interface, or enum expected
                            }
                            ^
linear_garden.java:51: error: class, interface, or enum expected
                        }
                        ^
linear_garden.java:55: error: class, interface, or enum expected
                         ret=0;
                         ^
linear_garden.java:56: error: class, interface, or enum expected
                           if(i==N){
                           ^
linear_garden.java:58: error: class, interface, or enum expected
                        continue;
                        ^
linear_garden.java:59: error: class, interface, or enum expected
                    }
                    ^
linear_garden.java:60: error: class, interface, or enum expected
                        for(int d=0;d<=1;d++)
                                    ^
linear_garden.java:60: error: class, interface, or enum expected
                        for(int d=0;d<=1;d++)
                                         ^
linear_garden.java:66: error: class, interface, or enum expected
                            else if(d==1&&where+1<5) ret+=dp[(i+1)&1][0][mn][max(mx,where+1)][where+1];
                            ^
linear_garden.java:67: error: class, interface, or enum expected
                            }
                            ^
linear_garden.java:71: error: class, interface, or enum expected
                            else if(d==1&&where+1<5) 
                            ^
linear_garden.java:73: error: class, interface, or enum expected
                            }
                            ^
linear_garden.java:75: error: class, interface, or enum expected
                        }
                        ^
linear_garden.java:83: error: class, interface, or enum expected
}
^
linear_garden.java:87: error: class, interface, or enum expected
    cin.tie(NULL);
    ^
linear_garden.java:90: error: class, interface, or enum expected
int tt=1;
^
linear_garden.java:93: error: class, interface, or enum expected
int T=1;
^
linear_garden.java:94: error: class, interface, or enum expected
while(tt--)
^
linear_garden.java:97: error: class, interface, or enum expected
cin>>s;
^
linear_garden.java:98: error: class, interface, or enum expected
for(int i=0;i<N;i++)
^
linear_garden.java:98: error: class, interface, or enum expected
for(int i=0;i<N;i++)
            ^
linear_garden.java:98: error: class, interface, or enum expected
for(int i=0;i<N;i++)
                ^
linear_garden.java:102: error: class, interface, or enum expected
    else s[i]='1';
    ^
linear_garden.java:103: error: class, interface, or enum expected
}
^
linear_garden.java:110: error: class, interface, or enum expected
}
^
55 errors