Submission #542157

#TimeUsernameProblemLanguageResultExecution timeMemory
542157AJ00Miners (IOI07_miners)C++14
9 / 100
1584 ms1684 KiB
#include <bits/stdc++.h> using namespace std; vector<int> vec1,vec2; deque<int> temp; int val[100000]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t=1,n,cur=0,ans=0; //cin >> t; string str; while (t--){ cin >> n; cin >> str; for (int i = 0; i < n; i++){ if (str[i] == 'M'){ val[i] = 0; } if (str[i] == 'F'){ val[i] = 1; } if (str[i] == 'B'){ val[i] = 2; } } for (int l = 0; l < (1<<n); l++){ vec1.clear(); vec2.clear(); for (int j = 0; j < n; j++){ if (l & (1 << j)){ vec1.push_back(val[j]); if (l == 19){ // cout << j << " "; } } else { vec2.push_back(val[j]); } } // reverse(vec1.begin(),vec1.end()); /* if (l == 19){ cout << "\n"; for (int i = 0; i < vec1.size(); i++){ cout << vec1[i] << " "; } cout << "\n"; for (int i = 0; i < vec2.size(); i++){ cout << vec2[i] << " "; } }*/ temp.clear(); cur = 0; if (!vec1.empty()){ cur = 1; temp.push_back(vec1[0]); if (vec1.size() >= 2){ cur += 1; cur += (vec1[0] != vec1[1]); temp.push_back(vec1[1]); } /* if (l==19){ cout << cur << "\n"; }*/ for (int i = 2; i < vec1.size(); i++){ if (vec1[i] == temp[0] == temp[1]){ cur += 1; } else if (vec1[i] == temp[0] || vec1[i] == temp[1] || temp[0] == temp[1]){ cur += 2; } else { cur += 3; } // cout << temp[0] << temp[1] << temp[2] << " "; temp.pop_front(); temp.push_back(vec1[i]); } } temp.clear(); if (!vec2.empty()){ cur += 1; temp.push_back(vec2[0]); if (vec2.size() >= 2){ cur += 1; cur += (vec2[0] != vec2[1]); temp.push_back(vec2[1]); } /* if (l==19){ cout << cur << "\n"; }*/ for (int i = 2; i < vec2.size(); i++){ if (vec2[i] == temp[0] == temp[1]){ cur += 1; } else if (vec2[i] == temp[0] || vec2[i] == temp[1] || temp[0] == temp[1]){ cur += 2; } else { cur += 3; } //cout << temp[0] << temp[1] << temp[2] << " "; temp.pop_front(); temp.push_back(vec2[i]); } } else { cur += 0; } /* if (l == 19){ cout << cur << "\n"; }*/ // cout << l << " " << cur << "\n"; ans = max(ans,cur); } cout << ans << "\n"; } return 0; }

Compilation message (stderr)

miners.cpp: In function 'int main()':
miners.cpp:65:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |                 for (int i = 2; i < vec1.size(); i++){
      |                                 ~~^~~~~~~~~~~~~
miners.cpp:66:33: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses]
   66 |                     if (vec1[i] == temp[0] == temp[1]){
miners.cpp:93:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |                 for (int i = 2; i < vec2.size(); i++){
      |                                 ~~^~~~~~~~~~~~~
miners.cpp:94:33: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses]
   94 |                     if (vec2[i] == temp[0] == temp[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...