Submission #288649

# Submission time Handle Problem Language Result Execution time Memory
288649 2020-09-01T17:44:32 Z LordOfIran Senior Postmen (BOI14_postmen) C++17
55 / 100
500 ms 59032 KB
//                             In The Name Of Allah                                           
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
//#define ll long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
const int N = 5e5 + 100, OO = 1e9 + 7, K = 1e7 + 4, T = 22, M = 1e9 + 7, P = 6151, SQ = 1300, lg = 22;
typedef pair <int, int> pii;
bool mark[N];
int num[N], ET[N], l[N], r[N], nw[N], ht[N], nxt = 0;
vector <int> v[N];

inline void dfs(int x) {
	for(; nw[x] < (int)v[x].size(); nw[x]++) {
		int p = v[x][nw[x]];
		if(mark[p])
			continue;
		mark[p] = true;
		dfs(l[p] ^ r[p] ^ x);
		ET[nxt++] = x;
	}
}

int32_t main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
		v[r[i]].pb(i);
		v[l[i]].pb(i);
	}
	dfs(1);
	int sz = -1;
	for(int i = 0; i < nxt; i++) {
		int u = ET[i];
		if(num[u]) {
			printf("%d", u);
			while(ht[sz] != u) 	
				printf(" %d", ht[sz]), num[ht[sz]]--, sz--;
			cout << "\n";
		}
		else 
			ht[++sz] = u, num[u]++;
	}
	for(int i = 0; i <= sz; i++)
		printf("%d ", ht[i]);
	return 0;
}

Compilation message

postmen.cpp: In function 'int32_t main()':
postmen.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12188 KB Output is correct
2 Correct 9 ms 12160 KB Output is correct
3 Correct 9 ms 12160 KB Output is correct
4 Correct 12 ms 12288 KB Output is correct
5 Correct 9 ms 12160 KB Output is correct
6 Correct 13 ms 12416 KB Output is correct
7 Correct 23 ms 13068 KB Output is correct
8 Correct 11 ms 12288 KB Output is correct
9 Correct 114 ms 17912 KB Output is correct
10 Correct 12 ms 12288 KB Output is correct
11 Correct 13 ms 12288 KB Output is correct
12 Correct 124 ms 18040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12160 KB Output is correct
2 Correct 9 ms 12160 KB Output is correct
3 Correct 8 ms 12160 KB Output is correct
4 Correct 12 ms 12288 KB Output is correct
5 Correct 10 ms 12160 KB Output is correct
6 Correct 12 ms 12416 KB Output is correct
7 Correct 28 ms 13008 KB Output is correct
8 Correct 11 ms 12288 KB Output is correct
9 Correct 111 ms 17812 KB Output is correct
10 Correct 12 ms 12288 KB Output is correct
11 Correct 12 ms 12288 KB Output is correct
12 Correct 131 ms 18040 KB Output is correct
13 Correct 172 ms 21344 KB Output is correct
14 Correct 165 ms 18680 KB Output is correct
15 Correct 153 ms 19824 KB Output is correct
16 Correct 173 ms 21496 KB Output is correct
17 Correct 166 ms 17144 KB Output is correct
18 Correct 164 ms 19320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12160 KB Output is correct
2 Correct 8 ms 12160 KB Output is correct
3 Correct 8 ms 12160 KB Output is correct
4 Correct 13 ms 12416 KB Output is correct
5 Correct 9 ms 12160 KB Output is correct
6 Correct 12 ms 12416 KB Output is correct
7 Correct 23 ms 13184 KB Output is correct
8 Correct 12 ms 12288 KB Output is correct
9 Correct 110 ms 17912 KB Output is correct
10 Correct 12 ms 12288 KB Output is correct
11 Correct 12 ms 12288 KB Output is correct
12 Correct 123 ms 18040 KB Output is correct
13 Correct 175 ms 21496 KB Output is correct
14 Correct 170 ms 18680 KB Output is correct
15 Correct 149 ms 19824 KB Output is correct
16 Correct 176 ms 21368 KB Output is correct
17 Correct 171 ms 17144 KB Output is correct
18 Correct 179 ms 19348 KB Output is correct
19 Execution timed out 1060 ms 59032 KB Time limit exceeded
20 Halted 0 ms 0 KB -