# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
740226 | 2023-05-12T07:39:30 Z | vjudge1 | 분수 공원 (IOI21_parks) | C++17 | 186 ms | 40448 KB |
#include "parks.h" #include<bits/stdc++.h> #define f first #define s second using namespace std; const int maxn = 2e5 + 100; int sum; int ord[maxn]; int used[maxn]; vector<int>g[maxn]; void dfs(int v){ used[v] = 1; sum++; for(auto to: g[v]){ if(!used[to]) dfs(to); } } int construct_roads(std::vector<int> x, std::vector<int> y){ int n = x.size(); if (x.size() == 1) { build({}, {}, {}, {}); return 1; } vector<pair<int, int>>c[2]; for(int i=0; i<n; i++){ int num = 0; if(x[i] == 4) num = 1; c[num].push_back({y[i], i}); } sort(c[0].begin(), c[0].end()); sort(c[1].begin(), c[1].end()); bool ok = 1; vector<int>u, v, a, b; if(c[1].size() == 0){ for(int i=1; i<n; i++){ if(c[0][i].first-c[0][i-1].first != 2) ok = 0; u.push_back(c[0][i-1].second); v.push_back(c[0][i].second); a.push_back(1); b.push_back(c[0][i].first-1); } } else{ for(int i=1; i<c[0].size(); i++){ u.push_back(c[0][i-1].second); v.push_back(c[0][i].second); a.push_back(1); b.push_back(c[0][i].first-1); g[c[0][i].s].push_back(c[0][i-1].s); g[c[0][i-1].s].push_back(c[0][i].s); } for(int i=1; i<c[1].size(); i++){ u.push_back(c[1][i-1].second); v.push_back(c[1][i].second); a.push_back(5); b.push_back(c[1][i].first-1); g[c[1][i].s].push_back(c[1][i-1].s); g[c[1][i-1].s].push_back(c[1][i].s); } int pos = 0; for(int i=0; i<c[0].size(); i++){ while(pos < c[1].size() && c[1][pos].f < c[0][i].f) pos++; if(pos < c[1].size() && c[1][pos].f == c[0][i].f){ u.push_back(c[0][i].s); v.push_back(c[1][pos].s); a.push_back(3); b.push_back(c[0][i].f-1); g[c[0][i].s].push_back(c[1][pos].s); g[c[1][pos].s].push_back(c[0][i].s); } } dfs(0); if(sum < n) ok = 0; } if(ok) build(u, v, a, b); return ok; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 2 ms | 4948 KB | Output is correct |
5 | Correct | 2 ms | 4948 KB | Output is correct |
6 | Correct | 2 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 4884 KB | Output is correct |
9 | Correct | 59 ms | 12848 KB | Output is correct |
10 | Correct | 9 ms | 5892 KB | Output is correct |
11 | Correct | 28 ms | 9080 KB | Output is correct |
12 | Correct | 9 ms | 6236 KB | Output is correct |
13 | Correct | 10 ms | 7240 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 5076 KB | Output is correct |
16 | Correct | 56 ms | 12820 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 2 ms | 4948 KB | Output is correct |
5 | Correct | 2 ms | 4948 KB | Output is correct |
6 | Correct | 2 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 4884 KB | Output is correct |
9 | Correct | 59 ms | 12848 KB | Output is correct |
10 | Correct | 9 ms | 5892 KB | Output is correct |
11 | Correct | 28 ms | 9080 KB | Output is correct |
12 | Correct | 9 ms | 6236 KB | Output is correct |
13 | Correct | 10 ms | 7240 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 5076 KB | Output is correct |
16 | Correct | 56 ms | 12820 KB | Output is correct |
17 | Correct | 3 ms | 4948 KB | Output is correct |
18 | Correct | 4 ms | 4948 KB | Output is correct |
19 | Correct | 3 ms | 4948 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Incorrect | 3 ms | 4948 KB | Pair u[1]=1 @(2, 4) and v[1]=5 @(2, 8) does not form a valid edge (distance != 2) |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 2 ms | 4948 KB | Output is correct |
5 | Correct | 2 ms | 4948 KB | Output is correct |
6 | Correct | 2 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 4884 KB | Output is correct |
9 | Correct | 59 ms | 12848 KB | Output is correct |
10 | Correct | 9 ms | 5892 KB | Output is correct |
11 | Correct | 28 ms | 9080 KB | Output is correct |
12 | Correct | 9 ms | 6236 KB | Output is correct |
13 | Correct | 10 ms | 7240 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 5076 KB | Output is correct |
16 | Correct | 56 ms | 12820 KB | Output is correct |
17 | Correct | 3 ms | 4948 KB | Output is correct |
18 | Correct | 4 ms | 4948 KB | Output is correct |
19 | Correct | 3 ms | 4948 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Incorrect | 3 ms | 4948 KB | Pair u[1]=1 @(2, 4) and v[1]=5 @(2, 8) does not form a valid edge (distance != 2) |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 2 ms | 4948 KB | Output is correct |
5 | Correct | 2 ms | 4948 KB | Output is correct |
6 | Correct | 2 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 4884 KB | Output is correct |
9 | Correct | 59 ms | 12848 KB | Output is correct |
10 | Correct | 9 ms | 5892 KB | Output is correct |
11 | Correct | 28 ms | 9080 KB | Output is correct |
12 | Correct | 9 ms | 6236 KB | Output is correct |
13 | Correct | 10 ms | 7240 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 5076 KB | Output is correct |
16 | Correct | 56 ms | 12820 KB | Output is correct |
17 | Incorrect | 2 ms | 4948 KB | Solution announced impossible, but it is possible. |
18 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 2 ms | 4948 KB | Output is correct |
5 | Correct | 2 ms | 4948 KB | Output is correct |
6 | Correct | 2 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 4884 KB | Output is correct |
9 | Correct | 59 ms | 12848 KB | Output is correct |
10 | Correct | 9 ms | 5892 KB | Output is correct |
11 | Correct | 28 ms | 9080 KB | Output is correct |
12 | Correct | 9 ms | 6236 KB | Output is correct |
13 | Correct | 10 ms | 7240 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 5076 KB | Output is correct |
16 | Correct | 56 ms | 12820 KB | Output is correct |
17 | Incorrect | 186 ms | 40448 KB | Pair u[0]=2 @(82816, 2) and v[0]=3 @(97624, 2) does not form a valid edge (distance != 2) |
18 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 2 ms | 4948 KB | Output is correct |
5 | Correct | 2 ms | 4948 KB | Output is correct |
6 | Correct | 2 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 4884 KB | Output is correct |
9 | Correct | 59 ms | 12848 KB | Output is correct |
10 | Correct | 9 ms | 5892 KB | Output is correct |
11 | Correct | 28 ms | 9080 KB | Output is correct |
12 | Correct | 9 ms | 6236 KB | Output is correct |
13 | Correct | 10 ms | 7240 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 5076 KB | Output is correct |
16 | Correct | 56 ms | 12820 KB | Output is correct |
17 | Correct | 3 ms | 4948 KB | Output is correct |
18 | Correct | 4 ms | 4948 KB | Output is correct |
19 | Correct | 3 ms | 4948 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Incorrect | 3 ms | 4948 KB | Pair u[1]=1 @(2, 4) and v[1]=5 @(2, 8) does not form a valid edge (distance != 2) |
22 | Halted | 0 ms | 0 KB | - |