Submission #537700

# Submission time Handle Problem Language Result Execution time Memory
537700 2022-03-15T11:45:30 Z Jarif_Rahman Ancient Machine (JOI21_ancient_machine) C++17
30 / 100
91 ms 9696 KB
#include "Anna.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

namespace {

}


void Anna(int n, vector<char> s){
    for(int i = 0; i < n; i++){
        if(s[i] == 'X') Send(0), Send(0);
        else if(s[i] == 'Y') Send(0), Send(1);
        else Send(1);
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

namespace {
}

void Bruno(int n, int m, vector<int> A){
    str s = "";
    for(int i = 0; i < m; i++){
        if(A[i] == 0){
            if(A[i+1] == 0) s+="X";
            else s+="Y";
            i++;
        }
        else s+="Z";
    }

    list<pair<int, char>> ls;

    for(int i = 0; i < n; i++) ls.pb({i, s[i]});

    for(auto it = ls.begin(); it != ls.end();){
        if(it == ls.begin() || prev(it)->sc != it->sc){
            it++;
            continue;
        }

        Remove(it->f);
        it = ls.erase(it);
    }

    while(!ls.empty() && ls.begin()->sc != 'X')
        Remove(ls.begin()->f), ls.erase(ls.begin());    
    while(!ls.empty() && prev(ls.end())->sc != 'Z')
        Remove(prev(ls.end())->f), ls.erase(prev(ls.end()));

    if(ls.empty()) return;

    for(auto it = ls.begin(); it != ls.end();){
        if(it->sc != 'Z'){
            it++;
            continue;
        }
        for(auto it2 = prev(it); it2 != ls.begin();)
            Remove(it2->f), it2 = ls.erase(it2), it2--;
        Remove(it->f);
        it = ls.erase(it);
    }

    Remove(ls.begin()->f);
    ls.erase(ls.begin());
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 612 KB Output is correct
5 Correct 1 ms 520 KB Output is correct
6 Correct 0 ms 512 KB Output is correct
7 Correct 0 ms 508 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 520 KB Output is correct
11 Correct 1 ms 576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 81 ms 9212 KB Partially correct
2 Partially correct 69 ms 9408 KB Partially correct
3 Partially correct 73 ms 9436 KB Partially correct
4 Partially correct 79 ms 9248 KB Partially correct
5 Partially correct 71 ms 9360 KB Partially correct
6 Partially correct 71 ms 9324 KB Partially correct
7 Partially correct 71 ms 9280 KB Partially correct
8 Partially correct 73 ms 9256 KB Partially correct
9 Partially correct 71 ms 9384 KB Partially correct
10 Partially correct 80 ms 9360 KB Partially correct
11 Partially correct 73 ms 9272 KB Partially correct
12 Partially correct 79 ms 9336 KB Partially correct
13 Partially correct 88 ms 9564 KB Partially correct
14 Partially correct 69 ms 8924 KB Partially correct
15 Partially correct 69 ms 9000 KB Partially correct
16 Partially correct 79 ms 9140 KB Partially correct
17 Partially correct 79 ms 9696 KB Partially correct
18 Partially correct 78 ms 9560 KB Partially correct
19 Partially correct 56 ms 8180 KB Partially correct
20 Partially correct 73 ms 9264 KB Partially correct
21 Partially correct 86 ms 9244 KB Partially correct
22 Partially correct 91 ms 9532 KB Partially correct
23 Partially correct 69 ms 9260 KB Partially correct
24 Partially correct 76 ms 9168 KB Partially correct
25 Partially correct 85 ms 9576 KB Partially correct
26 Partially correct 76 ms 9512 KB Partially correct
27 Partially correct 76 ms 9488 KB Partially correct
28 Partially correct 84 ms 9672 KB Partially correct
29 Partially correct 72 ms 9536 KB Partially correct
30 Partially correct 81 ms 9580 KB Partially correct
31 Partially correct 77 ms 9604 KB Partially correct
32 Partially correct 70 ms 9396 KB Partially correct
33 Partially correct 74 ms 9404 KB Partially correct