Submission #356252

# Submission time Handle Problem Language Result Execution time Memory
356252 2021-01-23T08:38:52 Z parsabahrami Senior Postmen (BOI14_postmen) C++17
55 / 100
500 ms 93716 KB
// Call my Name and Save me from The Dark
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
 
#define SZ(x)                       (int) x.size()
#define F                           first
#define S                           second

const int N = 5e5 + 10;
int M[N], ptr[N], from[N], to[N], n, m; vector<int> adj[N]; set<pii> tr;

void tour(int v) {
    while (ptr[v] < SZ(adj[v])) {
        int id = adj[v][ptr[v]++]; int u = from[id] ^ v ^ to[id];
        if (!M[id]) M[id] = 1, tour(u);
    }
    tr.insert({SZ(tr) + 1, v});
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d%d", &from[i], &to[i]);
        adj[from[i]].push_back(i);
        adj[to[i]].push_back(i);
    }
    for (int i = 1; i <= n; i++) assert(!(SZ(adj[i]) & 1));
    tour(1);
    memset(M, 0, sizeof M);
    for (auto it = tr.begin(); it != tr.end(); it = tr.upper_bound(*it)) {
        if (M[it->S]) {
            for (auto it2 = tr.lower_bound({M[it->S], it->S}); it2 != it;) {
                M[it2->S] = 0;
                printf("%d ", it2->S);
                it2 = tr.erase(it2);
            }
            printf("\n");
            M[it->S] = it->F;
        } else M[it->S] = it->F;
    }
    return 0;
}

Compilation message

postmen.cpp: In function 'int main()':
postmen.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |         scanf("%d%d", &from[i], &to[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 14060 KB Output is correct
2 Correct 11 ms 14060 KB Output is correct
3 Correct 10 ms 14060 KB Output is correct
4 Correct 12 ms 14444 KB Output is correct
5 Correct 10 ms 14188 KB Output is correct
6 Correct 14 ms 14572 KB Output is correct
7 Correct 20 ms 16108 KB Output is correct
8 Correct 12 ms 14464 KB Output is correct
9 Correct 97 ms 27116 KB Output is correct
10 Correct 12 ms 14316 KB Output is correct
11 Correct 12 ms 14444 KB Output is correct
12 Correct 97 ms 27244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14060 KB Output is correct
2 Correct 10 ms 14060 KB Output is correct
3 Correct 10 ms 14060 KB Output is correct
4 Correct 14 ms 14444 KB Output is correct
5 Correct 12 ms 14188 KB Output is correct
6 Correct 13 ms 14572 KB Output is correct
7 Correct 24 ms 16108 KB Output is correct
8 Correct 12 ms 14316 KB Output is correct
9 Correct 102 ms 27132 KB Output is correct
10 Correct 12 ms 14316 KB Output is correct
11 Correct 12 ms 14444 KB Output is correct
12 Correct 96 ms 27332 KB Output is correct
13 Correct 136 ms 29932 KB Output is correct
14 Correct 132 ms 25964 KB Output is correct
15 Correct 130 ms 28912 KB Output is correct
16 Correct 133 ms 29932 KB Output is correct
17 Correct 161 ms 23408 KB Output is correct
18 Correct 189 ms 27500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 14060 KB Output is correct
2 Correct 10 ms 14060 KB Output is correct
3 Correct 10 ms 14060 KB Output is correct
4 Correct 13 ms 14472 KB Output is correct
5 Correct 11 ms 14188 KB Output is correct
6 Correct 12 ms 14572 KB Output is correct
7 Correct 20 ms 16108 KB Output is correct
8 Correct 11 ms 14316 KB Output is correct
9 Correct 87 ms 27116 KB Output is correct
10 Correct 12 ms 14316 KB Output is correct
11 Correct 12 ms 14444 KB Output is correct
12 Correct 92 ms 27244 KB Output is correct
13 Correct 147 ms 30060 KB Output is correct
14 Correct 143 ms 25964 KB Output is correct
15 Correct 116 ms 28900 KB Output is correct
16 Correct 141 ms 29932 KB Output is correct
17 Correct 118 ms 23548 KB Output is correct
18 Correct 120 ms 27500 KB Output is correct
19 Execution timed out 869 ms 93716 KB Time limit exceeded
20 Halted 0 ms 0 KB -