# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
400051 | Joshc | Queue (CEOI06_queue) | C++11 | 283 ms | 18048 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define pii pair<int, int>
#define f first
#define s second
map<int, int> before, after;
map<int, pii> pos;
int prv(int x) {
return before.find(x) != before.end() ? before[x] : x-1;
}
int nxt(int x) {
return after.find(x) != after.end() ? after[x] : x+1;
}
int main() {
int n, a, b, cur=1, len=0;
char c;
scanf("%d", &n);
while (n--) {
scanf("%d%d", &a, &b);
if (b == cur) cur = a;
else if (a == cur) cur = nxt(a);
after[prv(a)] = nxt(a);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |