Submission #495606

#TimeUsernameProblemLanguageResultExecution timeMemory
495606PiejanVDCMiners (IOI07_miners)C++17
45 / 100
1588 ms3892 KiB
#include <bits/stdc++.h> using namespace std; string s; vector<char>v,w; int ans; void dfs(int i) { if(i == s.length()) { int cnt = 0; for(int j = 0 ; j < (int)v.size()-2 ; j++) { //assert(j+2 < v.size()); if(v[j] != v[j+1] && v[j] != v[j+2] && v[j+1] != v[j+2]) { cnt += 3; } else if(v[j] == v[j+1] && v[j] == v[j+2]) cnt++; else cnt += 2; } if(v.size() > 0) cnt++; if(v.size() > 1) cnt += (v[0] != v[1] ? 2 : 1); //cout << w.size() << " "; for(int j = 0 ; j < (int)w.size()-2 ; j++) { //assert(j+2 < w.size()); if(w[j] != w[j+1] && w[j] != w[j+2] && w[j+1] != w[j+2]) { cnt += 3; } else if(w[j] == w[j+1] && w[j] == w[j+2]) cnt++; else cnt += 2; } if(w.size() > 0) cnt++; if(w.size() > 1) cnt += (w[0] != w[1] ? 2 : 1); ans = max(ans,cnt); return; } v.push_back(s[i]); dfs(i+1); v.pop_back(); w.push_back(s[i]); dfs(i+1); w.pop_back(); } signed main() { int n; cin>>n; cin>>s; dfs(0); cout << ans; }

Compilation message (stderr)

miners.cpp: In function 'void dfs(int)':
miners.cpp:10:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     if(i == s.length()) {
      |        ~~^~~~~~~~~~~~~
#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...