Submission #9802081
Source Code Expand
#include <bits/stdc++.h> #define Inf 0x3f3f3f3f #define rg register using namespace std; const int Maxn = 1e5 + 5; typedef long long ll; typedef ll arr[Maxn]; ll min(ll x, ll y) { return x < y ? x : y; } ll max(ll x, ll y) { return x > y ? x : y; } inline ll read() { rg ll res = 0, sign = 1; rg char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') sign = -1; ch = getchar(); } do { res = (res << 3) + (res << 1) + (ch ^ 48); ch = getchar(); } while (isdigit(ch)); return res * sign; } int n; arr siz, fa; struct str { ll d; int id; bool operator<(str A) const { return d < A.d; } } p[Maxn]; int main() { int tmp, now, s; cin >> n; for (int i = 1; i <= n; i++) { p[i] = {read(), i}; siz[i] = 1; } sort(p + 1, p + n + 1); for (int i = n; i > 1; i--) { now = p[i].id; tmp = p[i].d - n + 2 * siz[now]; fa[now] = p[s = lower_bound(p + 1, p + n + 1, (str){tmp, 0}) - p].id; if (p[s].d != tmp) { puts("-1"); return 0; } siz[fa[now]] += siz[now]; } for (int i = 1; i <= n; i++) if (fa[i]) printf("%d %d\n", fa[i], i); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Distance Sums |
User | hsl2363 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1155 Byte |
Status | WA |
Exec Time | 18 ms |
Memory | 2560 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:60:30: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll {aka long long int}’ [-Wformat=] printf("%d %d\n", fa[i], i); ^
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 900 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 4.txt, 40.txt, 41.txt, 42.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 1 ms | 256 KB |
10.txt | WA | 17 ms | 2560 KB |
11.txt | AC | 17 ms | 2560 KB |
12.txt | AC | 17 ms | 2560 KB |
13.txt | AC | 17 ms | 2560 KB |
14.txt | WA | 17 ms | 2560 KB |
15.txt | WA | 17 ms | 2560 KB |
16.txt | WA | 17 ms | 2560 KB |
17.txt | WA | 17 ms | 2560 KB |
18.txt | AC | 17 ms | 2560 KB |
19.txt | WA | 17 ms | 2560 KB |
2.txt | AC | 1 ms | 256 KB |
20.txt | WA | 17 ms | 2560 KB |
21.txt | AC | 15 ms | 2304 KB |
22.txt | WA | 17 ms | 2560 KB |
23.txt | WA | 17 ms | 2560 KB |
24.txt | WA | 15 ms | 2304 KB |
25.txt | AC | 17 ms | 2560 KB |
26.txt | AC | 16 ms | 2560 KB |
27.txt | AC | 17 ms | 2560 KB |
28.txt | AC | 17 ms | 2560 KB |
29.txt | WA | 17 ms | 2560 KB |
3.txt | AC | 4 ms | 640 KB |
30.txt | WA | 17 ms | 2560 KB |
31.txt | WA | 17 ms | 2560 KB |
32.txt | WA | 17 ms | 2560 KB |
33.txt | AC | 17 ms | 2560 KB |
34.txt | WA | 17 ms | 2560 KB |
35.txt | AC | 17 ms | 2560 KB |
36.txt | AC | 17 ms | 2560 KB |
37.txt | WA | 17 ms | 2560 KB |
38.txt | WA | 17 ms | 2560 KB |
39.txt | WA | 17 ms | 2560 KB |
4.txt | AC | 3 ms | 512 KB |
40.txt | WA | 17 ms | 2560 KB |
41.txt | WA | 17 ms | 2560 KB |
42.txt | WA | 14 ms | 2176 KB |
5.txt | AC | 18 ms | 2432 KB |
6.txt | WA | 17 ms | 2560 KB |
7.txt | WA | 17 ms | 2560 KB |
8.txt | WA | 17 ms | 2560 KB |
9.txt | WA | 17 ms | 2560 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | WA | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |