Submission #975274

#TimeUsernameProblemLanguageResultExecution timeMemory
975274canadavid1Editor (BOI15_edi)C++14
20 / 100
3059 ms2292 KiB
#include <iostream>
#include <vector>
#include <queue>
#include <set>

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for(auto& i : a) std::cin >> i;
    std::vector<int> which;
    std::vector<bool> undone;
    // for(auto i : a) std::cerr << i << "\t"; std::cerr << "\n";
    for(auto op : a)
    {
        undone.push_back(0);
        which.push_back(-1);
        // for(auto i : undone) std::cerr << i << "\t"; std::cerr << "\n";
        // for(auto i : which) std::cerr << i << "\t"; std::cerr << "\n";
        if (op < 0)
        {
            op = -op;
            int wh = which.size()-2;
            while(-a[wh] >= op || undone[wh]) {wh--;}
                // this is slow
            which.back() = wh;
            auto s = wh;
            while(s > -1) {undone[s] = !undone[s]; s = which[s];} // pointer sequence but eh
                // this is slow
        }
        int state = 0;
        for(int i = 0; i < undone.size(); i++) if(!undone[i] && a[i] > 0) state = a[i];
            // this is slow
        std::cout << state << "\n";
    }
}
/*
    0 1 2  3  4  5
    1 2 -1 -2 -3 -2
    A U A
    A A U  A
    A U A  U  A
    A A U  U  A  A
        1  2  3  2
*/

Compilation message (stderr)

edi.cpp: In function 'int main()':
edi.cpp:33:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i = 0; i < undone.size(); i++) if(!undone[i] && a[i] > 0) state = a[i];
      |                        ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...