제출 #643725

#제출 시각아이디문제언어결과실행 시간메모리
643725Cyber_WolfMiners (IOI07_miners)C++14
33 / 100
1588 ms996 KiB
// Problem: P4 - Miners // Contest: DMOJ - IOI '07 // URL: https://dmoj.ca/problem/ioi07p4 // Memory Limit: 16 MB // Time Limit: 750 ms // // Powered by CP Editor (https://cpeditor.org) #include <bits/stdc++.h> using namespace std; #define lg int #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); const lg N = 1e5+5; //lg dp[N][256]; lg n; string s; vector<lg> v(N); // lg solve(lg idx, lg bit) // { // if(idx == n) // { // return 0; // } // auto &ret = dp[idx][bit]; // if(~ret) return ret; // lg x = ((bit/64)&3), y = ((bit/16)&3), a = ((bit/4)&3), b = (bit&3); // set<lg> se1; // if(v[idx] != 3) se1.insert(v[idx]); // if(x != 3) se1.insert(x); // if(y != 3) se1.insert(y); // set<lg> se2; // if(v[idx] != 3) se2.insert(v[idx]); // if(a != 3) se2.insert(a); // if(b != 3) se2.insert(b); // lg ch1 = solve(idx+1, v[idx]*64+x*16+a*4+b)+se1.size(); // lg ch2 = solve(idx+1, x*64+y*16+v[idx]*4+a)+se2.size(); // return ret = max(ch1, ch2); // } int main() { fastio; cin >> n >> s; for(int i = 0; i < n; i++) { if(s[i] == 'M') v[i] = 1; if(s[i] == 'B') v[i] = 2; } vector<lg> dp(256, LLONG_MIN); dp[255] = 0; for(int i = 0; i < n; i++) { vector<lg> new_dp(256, LLONG_MIN); for(int j = 0; j < 256; j++) { lg x = ((j>>6)&3), y = ((j>>4)&3), a = ((j>>2)&3), b = (j&3); set<lg> se1; if(v[i] != 3) se1.insert(v[i]); if(x != 3) se1.insert(x); if(y != 3) se1.insert(y); set<lg> se2; if(v[i] != 3) se2.insert(v[i]); if(a != 3) se2.insert(a); if(b != 3) se2.insert(b); new_dp[j] = max(dp[v[i]*64+x*16+a*4+b]+se1.size(), dp[x*64+y*16+v[i]*4+a]+se2.size()); } dp = new_dp; } cout << dp[255] << '\n'; return 0; }

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

miners.cpp: In function 'int main()':
miners.cpp:55:21: warning: overflow in conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} changes value from '-9223372036854775808' to '0' [-Woverflow]
   55 |  vector<lg> dp(256, LLONG_MIN);
      |                     ^~~~~~~~~
miners.cpp:59:26: warning: overflow in conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} changes value from '-9223372036854775808' to '0' [-Woverflow]
   59 |   vector<lg> new_dp(256, LLONG_MIN);
      |                          ^~~~~~~~~
#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...