Submission #241883

# Submission time Handle Problem Language Result Execution time Memory
241883 2020-06-26T08:41:31 Z SorahISA Birmingham (COCI20_birmingham) C++17
70 / 70
157 ms 10620 KB
#include <bits/stdc++.h>
using namespace std;

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

int main() {
    fastIO();
    
    int n, m, q, k, tmp, u, v;
    queue<int> bfs;
    cin >> n >> m >> q >> k;
    
    vector<int> adj[n], dis(n, -1);
    
    while (q--) {
        cin >> tmp, --tmp;
        dis[tmp] = 0;
        bfs.push(tmp);
    }
    
    for (int i = 0; i < m; ++i) {
        cin >> u >> v, --u, --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    while (!bfs.empty()) {
        int nxt = bfs.front(); bfs.pop();
        for (auto x : adj[nxt]) {
            if (dis[x] == -1) {
                dis[x] = dis[nxt] + 1;
                bfs.push(x);
            }
        }
    }
    
    int trans[n];
    trans[0] = 0;
    for (int i = 1, tok = 1; tok < n; ++i) {
        for (int j = 0; j < i*k and tok < n; ++j, ++tok) {
            trans[tok] = i;
        }
    }
    
    for (int i = 0; i < n; ++i) cout << trans[dis[i]] << " \n"[i == n-1];
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 9816 KB Output is correct
2 Correct 108 ms 10296 KB Output is correct
3 Correct 115 ms 10616 KB Output is correct
4 Correct 81 ms 9336 KB Output is correct
5 Correct 85 ms 9592 KB Output is correct
6 Correct 105 ms 10616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 10360 KB Output is correct
2 Correct 115 ms 10100 KB Output is correct
3 Correct 135 ms 10360 KB Output is correct
4 Correct 105 ms 10488 KB Output is correct
5 Correct 106 ms 10104 KB Output is correct
6 Correct 113 ms 10104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 9976 KB Output is correct
2 Correct 110 ms 10488 KB Output is correct
3 Correct 157 ms 10620 KB Output is correct
4 Correct 153 ms 10616 KB Output is correct
5 Correct 95 ms 9720 KB Output is correct
6 Correct 93 ms 10104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 9512 KB Output is correct
2 Correct 97 ms 10104 KB Output is correct
3 Correct 104 ms 10368 KB Output is correct
4 Correct 145 ms 9848 KB Output is correct
5 Correct 101 ms 9464 KB Output is correct
6 Correct 113 ms 9976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 9592 KB Output is correct
2 Correct 106 ms 9848 KB Output is correct
3 Correct 100 ms 9764 KB Output is correct
4 Correct 108 ms 9852 KB Output is correct
5 Correct 122 ms 9848 KB Output is correct
6 Correct 120 ms 9848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 9592 KB Output is correct
2 Correct 105 ms 10064 KB Output is correct
3 Correct 88 ms 9848 KB Output is correct
4 Correct 96 ms 10104 KB Output is correct
5 Correct 98 ms 9720 KB Output is correct
6 Correct 89 ms 10104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 9848 KB Output is correct
2 Correct 82 ms 9340 KB Output is correct
3 Correct 112 ms 10616 KB Output is correct
4 Correct 92 ms 9720 KB Output is correct
5 Correct 108 ms 10028 KB Output is correct
6 Correct 105 ms 10616 KB Output is correct