QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#342346 | #4087. 철도 | Unknown1508 | 0 | 0ms | 3980kb | C++20 | 1.6kb | 2024-03-01 10:49:34 | 2024-03-01 10:49:36 |
answer
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
vector<vector<int>> build_adj(int N, const vector<ii> &E){
vector<vector<int>> adj(N);
for (auto [x, y]: E){
adj[x-1].push_back(y-1);
adj[y-1].push_back(x-1);
}
return adj;
}
vector<int> bfs(int N, int K, int root, const vector<vector<int>> &adj){
vector<int> layer(N, N);
queue<int> q;
layer[root] = 0; q.push(root);
while (!q.empty()){
int x = q.front(); q.pop();
for (auto k: adj[x]){
if (layer[k] == N){
layer[k] = layer[x] + 1;
q.push(k);
}
}
}
vector<int> cnt(N+1, 0);
long long res = 0;
for (int i = 0; i < N; i++) res += (cnt[layer[i]]++);
if (res >= K) return layer;
return {};
}
vector<ii> encode_map(int N, int K, int &X, vector<ii> E){
auto adj = build_adj(N, E);
vector<ii> result = E;
for (int i = 0; i < N; i++){
auto layer = bfs(N, K, i, adj);
if (layer.empty()) continue;
vector<vector<int>> v(N + 1);
for (int j = 0; j < N; j++){
v[layer[j]].push_back(j);
}
for (int c = 0; c < N; c++){
if (!K) break;
for (int idx1 = 0; idx1 < (int)v[c].size(); idx1++){
if (!K) break;
for (int idx2 = idx1 + 1; idx2 < (int)v[c].size(); idx2++){
if (!K) break;
K--;
result.emplace_back(v[c][idx1] + 1, v[c][idx2] + 1);
}
}
}
X = i+1;
break;
}
return result;
}
vector<ii> decode_map(int N, int K, int X, vector<ii> E){
auto adj = build_adj(N, E);
auto layer = bfs(N, K, X-1, adj);
vector<ii> result;
for (auto [x, y]: E){
if (layer[x-1] != layer[y-1]) result.emplace_back(x, y);
}
return result;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3732kb
input:
jlsvaji35cwcxva-INPUT-gwl9ravworar2t1 200 4 1 2 3 3 1 4 1 4 1 1 4 3 1 2 1 4 1 4 3 1 3 2 1 3 1 2 1 3 1 4 1 1 4 4 3 2 3 4 1 3 1 1 4 2 1 3 1 1 3 2 1 4 1 2 4 1 2 3 4 4 1 2 3 1 3 4 1 4 1 3 1 1 4 2 3 4 1 3 2 1 4 4 2 3 1 3 1 2 3 4 1 2 4 1 4 4 3 3 1 3 1 2 1 3 1 1 3 2 3 4 1 2 4 4 1 3 1 4 1 2 4 1 4 3 1 3 1 2 ...
output:
xesbjgyk879wak7-PIPE-o4pbvexzrdpcje2 WA invalid edge count - encode
input:
xesbjgyk879wak7-PIPE-o4pbvexzrdpcje2 WA invalid edge count - encode
output:
wji3t9iql4gwq1n-OUTPUT-s6f20p5z2lkxbj3 WA invalid edge count - encode
result:
wrong answer WA in grader: invalid edge count - encode
Subtask #2:
score: 0
Skipped
Subtask #3:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 0ms
memory: 3980kb
input:
jlsvaji35cwcxva-INPUT-gwl9ravworar2t1 196 24 11 13 17 4 8 22 19 15 13 10 14 6 10 9 6 23 1 1 15 5 9 12 23 16 21 8 5 11 24 2 22 21 11 18 3 3 20 20 12 17 7 19 18 24 2 14 16 22 10 16 11 3 15 6 5 17 19 15 17 11 18 20 10 8 1 14 22 4 3 22 8 2 21 12 14 1 9 19 12 7 4 10 13 18 7 21 16 5 2 13 6 42 6 11 24 14 3...
output:
xesbjgyk879wak7-PIPE-o4pbvexzrdpcje2 WA invalid edge count - encode
input:
xesbjgyk879wak7-PIPE-o4pbvexzrdpcje2 WA invalid edge count - encode
output:
wji3t9iql4gwq1n-OUTPUT-s6f20p5z2lkxbj3 WA invalid edge count - encode
result:
wrong answer WA in grader: invalid edge count - encode
Subtask #4:
score: 0
Wrong Answer
Test #72:
score: 0
Wrong Answer
time: 0ms
memory: 3796kb
input:
jlsvaji35cwcxva-INPUT-gwl9ravworar2t1 196 146 27 27 45 119 45 4 45 61 45 1 45 115 45 51 45 16 45 134 45 83 45 64 45 86 45 7 45 62 45 78 45 46 17 128 45 30 17 41 45 14 45 12 45 52 45 32 45 139 45 96 45 84 45 116 17 11 45 72 131 42 45 105 45 106 45 130 45 125 45 127 45 112 45 22 45 100 17 70 17 43 45 ...
output:
xesbjgyk879wak7-PIPE-o4pbvexzrdpcje2 WA invalid edge count - encode
input:
xesbjgyk879wak7-PIPE-o4pbvexzrdpcje2 WA invalid edge count - encode
output:
wji3t9iql4gwq1n-OUTPUT-s6f20p5z2lkxbj3 WA invalid edge count - encode
result:
wrong answer WA in grader: invalid edge count - encode
Subtask #5:
score: 0
Skipped