제출 #458383

#제출 시각아이디문제언어결과실행 시간메모리
458383thomas_liMiners (IOI07_miners)C++17
84 / 100
1591 ms588 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; const int MM = 1e5+5; int n,dp[2][4][4][4][4][4][4],ans[4][4][4]; // add extra state for empty int vals[MM][3],ptr = 0; char mp[256]; int main(){ cin.tie(0)->sync_with_stdio(0); cin >> n; string s; cin >> s; s = ' ' + s; memset(dp,-0x3f,sizeof dp); mp['M'] = 1; mp['F'] = 2; mp['B'] = 3; dp[0][0][0][0][0][0][0] = 0; auto smax = [&](int& x, int y){ x = max(x,y); }; auto coal = [&](int x, int y, int z){ set<int> s; if(x > 0) s.insert(x); if(y > 0) s.insert(y); if(z > 0) s.insert(z); ans[x][y][z] = (int)s.size(); }; for(int i = 0; i <= 3; i++){ for(int j = 0; j <= 3; j++){ for(int k = 0; k <= 3; k++){ // if there are 0s, they must be a prefix if(i == 0 && k == 0 && !(j == 0)) continue; if(j == 0 && k == 0 && !(i == 0)) continue; if(k == 0 && !(j == 0) && !(i == 0)) continue; if(j == 0 && !(k == 0) && !(i == 0)) continue; vals[ptr][2] = k; vals[ptr][1] = j; vals[ptr++][0] = i; coal(i,j,k); } } } int res = 0,val; for(int i = 0; i < n; i++){ int cur = i & 1, nxt = !cur; for(int j = 0; j < ptr; j++){ for(int k = 0; k < ptr; k++){ val = dp[cur][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][0]][vals[k][1]][vals[k][2]]; if(val < 0) continue; // add i+1 to a smax(dp[nxt][vals[j][1]][vals[j][2]][mp[s[i+1]]][vals[k][0]][vals[k][1]][vals[k][2]],val+ans[vals[j][1]][vals[j][2]][mp[s[i+1]]]); // add i+1 to b smax(dp[nxt][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][1]][vals[k][2]][mp[s[i+1]]],val+ans[vals[k][1]][vals[k][2]][mp[s[i+1]]]); if(i+1 == n){ smax(res,dp[nxt][vals[j][1]][vals[j][2]][mp[s[i+1]]][vals[k][0]][vals[k][1]][vals[k][2]]); smax(res,dp[nxt][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][1]][vals[k][2]][mp[s[i+1]]]); } } } // prep cur row for next i } cout << res << "\n"; }

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

miners.cpp: In function 'int main()':
miners.cpp:53:63: warning: array subscript has type 'char' [-Wchar-subscripts]
   53 |                 smax(dp[nxt][vals[j][1]][vals[j][2]][mp[s[i+1]]][vals[k][0]][vals[k][1]][vals[k][2]],val+ans[vals[j][1]][vals[j][2]][mp[s[i+1]]]);
      |                                                               ^
miners.cpp:53:63: warning: array subscript has type 'char' [-Wchar-subscripts]
   53 |                 smax(dp[nxt][vals[j][1]][vals[j][2]][mp[s[i+1]]][vals[k][0]][vals[k][1]][vals[k][2]],val+ans[vals[j][1]][vals[j][2]][mp[s[i+1]]]);
      |                                                      ~~~~~~~~~^
miners.cpp:53:143: warning: array subscript has type 'char' [-Wchar-subscripts]
   53 |                 smax(dp[nxt][vals[j][1]][vals[j][2]][mp[s[i+1]]][vals[k][0]][vals[k][1]][vals[k][2]],val+ans[vals[j][1]][vals[j][2]][mp[s[i+1]]]);
      |                                                                                                                                               ^
miners.cpp:53:143: warning: array subscript has type 'char' [-Wchar-subscripts]
   53 |                 smax(dp[nxt][vals[j][1]][vals[j][2]][mp[s[i+1]]][vals[k][0]][vals[k][1]][vals[k][2]],val+ans[vals[j][1]][vals[j][2]][mp[s[i+1]]]);
      |                                                                                                                                      ~~~~~~~~~^
miners.cpp:55:99: warning: array subscript has type 'char' [-Wchar-subscripts]
   55 |                 smax(dp[nxt][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][1]][vals[k][2]][mp[s[i+1]]],val+ans[vals[k][1]][vals[k][2]][mp[s[i+1]]]);
      |                                                                                                   ^
miners.cpp:55:99: warning: array subscript has type 'char' [-Wchar-subscripts]
   55 |                 smax(dp[nxt][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][1]][vals[k][2]][mp[s[i+1]]],val+ans[vals[k][1]][vals[k][2]][mp[s[i+1]]]);
      |                                                                                          ~~~~~~~~~^
miners.cpp:55:143: warning: array subscript has type 'char' [-Wchar-subscripts]
   55 |                 smax(dp[nxt][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][1]][vals[k][2]][mp[s[i+1]]],val+ans[vals[k][1]][vals[k][2]][mp[s[i+1]]]);
      |                                                                                                                                               ^
miners.cpp:55:143: warning: array subscript has type 'char' [-Wchar-subscripts]
   55 |                 smax(dp[nxt][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][1]][vals[k][2]][mp[s[i+1]]],val+ans[vals[k][1]][vals[k][2]][mp[s[i+1]]]);
      |                                                                                                                                      ~~~~~~~~~^
miners.cpp:57:71: warning: array subscript has type 'char' [-Wchar-subscripts]
   57 |                     smax(res,dp[nxt][vals[j][1]][vals[j][2]][mp[s[i+1]]][vals[k][0]][vals[k][1]][vals[k][2]]);
      |                                                                       ^
miners.cpp:57:71: warning: array subscript has type 'char' [-Wchar-subscripts]
   57 |                     smax(res,dp[nxt][vals[j][1]][vals[j][2]][mp[s[i+1]]][vals[k][0]][vals[k][1]][vals[k][2]]);
      |                                                              ~~~~~~~~~^
miners.cpp:58:107: warning: array subscript has type 'char' [-Wchar-subscripts]
   58 |                     smax(res,dp[nxt][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][1]][vals[k][2]][mp[s[i+1]]]);
      |                                                                                                           ^
miners.cpp:58:107: warning: array subscript has type 'char' [-Wchar-subscripts]
   58 |                     smax(res,dp[nxt][vals[j][0]][vals[j][1]][vals[j][2]][vals[k][1]][vals[k][2]][mp[s[i+1]]]);
      |                                                                                                  ~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...