Submission #227157

# Submission time Handle Problem Language Result Execution time Memory
227157 2020-04-26T09:25:20 Z Bruteforceman Senior Postmen (BOI14_postmen) C++11
100 / 100
339 ms 35320 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
struct edge {
  int l, r;
  int nxtL, nxtR;
} e[maxn];
int idx[maxn];
int del[maxn];
int st[maxn];
int id;

void dfs(int x) {
  while(idx[x] != -1) {
    int i = idx[x]; 
    int y = e[i].l ^ e[i].r ^ x;
    idx[x] = (e[i].l == x) ? e[i].nxtL : e[i].nxtR;
    if(del[i]) continue; del[i] = true;
    dfs(y);
  }
  st[id++] = x;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  memset(idx, -1, sizeof idx);
  for(int i = 0; i < m; i++) {
    scanf("%d %d", &e[i].l, &e[i].r);
    e[i].nxtL = idx[e[i].l];
    e[i].nxtR = idx[e[i].r];
    idx[e[i].l] = idx[e[i].r] = i;
  }
  dfs(1);
  memset(del, false, sizeof del);
  stack <int> s;
  for(int i = 0; i < id; i++) {
    int x = st[i];
    s.push(x);
    if(del[x]) {
      do {
        printf("%d ", s.top());
        del[s.top()] = false;
        s.pop();
      } while(x != s.top() || !puts(""));
    } 
    del[x] = true;
  }
  return 0;
}

Compilation message

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:18:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(del[i]) continue; del[i] = true;
     ^~
postmen.cpp:18:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     if(del[i]) continue; del[i] = true;
                          ^~~
postmen.cpp: In function 'int main()':
postmen.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
postmen.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &e[i].l, &e[i].r);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4224 KB Output is correct
2 Correct 7 ms 4224 KB Output is correct
3 Correct 6 ms 4224 KB Output is correct
4 Correct 7 ms 4352 KB Output is correct
5 Correct 7 ms 4352 KB Output is correct
6 Correct 8 ms 4480 KB Output is correct
7 Correct 13 ms 5120 KB Output is correct
8 Correct 8 ms 4352 KB Output is correct
9 Correct 47 ms 9720 KB Output is correct
10 Correct 8 ms 4352 KB Output is correct
11 Correct 7 ms 4352 KB Output is correct
12 Correct 48 ms 9848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4224 KB Output is correct
2 Correct 6 ms 4224 KB Output is correct
3 Correct 7 ms 4224 KB Output is correct
4 Correct 8 ms 4352 KB Output is correct
5 Correct 7 ms 4352 KB Output is correct
6 Correct 9 ms 4480 KB Output is correct
7 Correct 12 ms 4992 KB Output is correct
8 Correct 8 ms 4352 KB Output is correct
9 Correct 48 ms 9720 KB Output is correct
10 Correct 8 ms 4352 KB Output is correct
11 Correct 8 ms 4352 KB Output is correct
12 Correct 49 ms 9720 KB Output is correct
13 Correct 52 ms 10360 KB Output is correct
14 Correct 53 ms 8568 KB Output is correct
15 Correct 51 ms 9828 KB Output is correct
16 Correct 51 ms 10348 KB Output is correct
17 Correct 51 ms 7032 KB Output is correct
18 Correct 51 ms 9208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4224 KB Output is correct
2 Correct 6 ms 4224 KB Output is correct
3 Correct 6 ms 4224 KB Output is correct
4 Correct 8 ms 4352 KB Output is correct
5 Correct 7 ms 4352 KB Output is correct
6 Correct 8 ms 4480 KB Output is correct
7 Correct 13 ms 5120 KB Output is correct
8 Correct 11 ms 4352 KB Output is correct
9 Correct 55 ms 9696 KB Output is correct
10 Correct 8 ms 4352 KB Output is correct
11 Correct 7 ms 4352 KB Output is correct
12 Correct 53 ms 9720 KB Output is correct
13 Correct 52 ms 10336 KB Output is correct
14 Correct 53 ms 8568 KB Output is correct
15 Correct 49 ms 9848 KB Output is correct
16 Correct 54 ms 10408 KB Output is correct
17 Correct 58 ms 7076 KB Output is correct
18 Correct 50 ms 9208 KB Output is correct
19 Correct 339 ms 35168 KB Output is correct
20 Correct 330 ms 26476 KB Output is correct
21 Correct 260 ms 32392 KB Output is correct
22 Correct 307 ms 35320 KB Output is correct
23 Correct 201 ms 31612 KB Output is correct
24 Correct 282 ms 18940 KB Output is correct
25 Correct 271 ms 29664 KB Output is correct