QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#342275#4087. 철도bachbeo20070 0ms0kbC++231.7kb2024-03-01 10:17:322024-03-01 10:17:32

Judging History

你现在查看的是最新测评结果

  • [2024-03-01 10:17:32]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-03-01 10:17:32]
  • 提交

answer

#include "railroad.h"
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>

std::vector<pii> encode_map(int N, int K, int &X, std::vector<pii> E) {
    vector<pii> res;
    vector<vector<int>> edge(N+1);
    for(auto [u,v]:E){
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    X=-1;
    for(int i=1;i<=N;i++){
        int total=0;
        vector<int> cnt(N,0);
        function<void(int,int,int)> dfs = [&](int u,int p,int d){
            total+=cnt[d];cnt[d]++;
            for(int v:edge[u]) if(v!=p) dfs(v,u,d+1);
        };
        dfs(i,0,0);
        if(total>=K){
            X=i;
            break;
        }
    }
    assert(X!=-1);
    vector<vector<int>> dd(N);
    function<void(int,int,int)> dfs2 = [&](int u,int p,int d){
        for(int i=0;i<min(K,(int)dd[d].size());i++){
            if(!K) break;
            K--;
            res.push_back({u,dd[d][i]});
        }
        dd[d].push_back(u);
        for(int v:edge[u]) if(v!=p) dfs2(v,u,d+1);
    };
    dfs2(X,0,0);
    assert((int)res.size()==K);
	return res;
}

std::vector<std::pair<int, int> > decode_map(int N, int K, int X, std::vector<std::pair<int, int> > E) {
	vector<pii> res;
    vector<vector<int>> edge(N+1);
    vector<bool> check(N+1,false);
    for(auto [u,v]:E){
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    vector<int> cur={X};
    while(!cur.empty()){
        vector<int> nxt;
        for(int u:cur) check[u]=true;
        for(int u:cur){
            for(int v:edge[u]){
                if(!check[v]){
                    res.push_back({u,v});
                    nxt.push_back(v);
                }
            }
        }
        swap(nxt,cur);
    }
    return res;
}

详细

Subtask #1:

score: 0
Stage 1: Program answer Runtime Error

Test #1:

score: 0
Stage 1: Program answer Runtime Error

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:


input:


output:


result:


Subtask #2:

score: 0
Skipped

Subtask #3:

score: 0
Stage 1: Program answer Runtime Error

Test #37:

score: 0
Stage 1: Program answer Runtime Error

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:


input:


output:


result:


Subtask #4:

score: 0
Stage 1: Program answer Runtime Error

Test #72:

score: 0
Stage 1: Program answer Runtime Error

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:


input:


output:


result:


Subtask #5:

score: 0
Skipped