Submission #542157

# Submission time Handle Problem Language Result Execution time Memory
542157 2022-03-25T14:53:49 Z AJ00 Miners (IOI07_miners) C++14
9 / 100
1500 ms 1684 KB
#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

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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 271 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1578 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1583 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 118 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1584 ms 1496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1684 KB Output isn't correct
2 Halted 0 ms 0 KB -