제출 #495609

#제출 시각아이디문제언어결과실행 시간메모리
495609PiejanVDCMiners (IOI07_miners)C++17
43 / 100
1590 ms3772 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; } if(!v.empty() && v.back() != s[i] && !w.empty() && w.back() == s[i]) { v.push_back(s[i]); dfs(i+1); v.pop_back(); } else if(!w.empty() && w.back() != s[i] && !v.empty() && v.back() == s[i]) { w.push_back(s[i]); dfs(i+1); w.pop_back(); } else { 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; }

컴파일 시 표준 에러 (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...