답안 #845114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845114 2023-09-06T12:00:55 Z vjudge1 Birmingham (COCI20_birmingham) C++17
70 / 70
110 ms 10956 KB
#include <bits/stdc++.h>
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
using namespace std;
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi> 
#define pc __builtin_popcountll
#define vp vector<pii>
#define sp << " " << 
#define all(x) x.bg()+1,x.end()
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back 
const int inf = 1e18;
const int MOD = 998244353;   
const int N = 2e5+1;


void solve() {
    int n,m,Q,k;
    cin >> n >> m >> Q >> k;
    vi edges[n+1];
    vi people;
    F(i,Q) {
        int p;
        cin >> p;
        people.pb(p);
    }
    F(i,m) {
        int a,b;
        cin >> a >> b;
        edges[a].pb(b);
        edges[b].pb(a);
    }
    queue<int> q;
    vi dists(n+1,inf);
    F(i,Q) dists[people[i-1]] = 0;
    for (auto it : people) {
        q.push(it);
    }
    while (!q.empty()) {
        int f = q.front();
        q.pop();
        for (auto nb : edges[f]) {
            if (dists[nb] == inf) {
                dists[nb] = dists[f]+1;
                q.push(nb);
            }
        }
    }
    F(i,n) {
        int l = 0;
        int r = 100000;
        while (l<=r) {
            int mid = (l+r) >> 1;
            if (mid*(mid+1)/2*k >= dists[i]) r = mid-1;
            else l = mid+1;
        }
        dists[i] = l;
    }
    F(i,n) cout << dists[i] << " ";
    cout << endl;
}    



signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef Local
        freopen("input.in", "r", stdin);
        freopen("input.out", "w", stdout);  
    #endif
    int t = 1;
    //cin >> t;
    while (t --> 0) solve();
}

Compilation message

birmingham.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    2 | #pragma optimize "DostSeferoğlu"
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 452 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 9816 KB Output is correct
2 Correct 89 ms 10320 KB Output is correct
3 Correct 90 ms 10912 KB Output is correct
4 Correct 60 ms 9296 KB Output is correct
5 Correct 91 ms 9532 KB Output is correct
6 Correct 80 ms 10800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 10232 KB Output is correct
2 Correct 73 ms 10064 KB Output is correct
3 Correct 73 ms 10360 KB Output is correct
4 Correct 109 ms 10400 KB Output is correct
5 Correct 81 ms 10096 KB Output is correct
6 Correct 74 ms 10100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 9952 KB Output is correct
2 Correct 110 ms 10500 KB Output is correct
3 Correct 93 ms 10692 KB Output is correct
4 Correct 99 ms 10252 KB Output is correct
5 Correct 65 ms 9636 KB Output is correct
6 Correct 82 ms 10340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 9300 KB Output is correct
2 Correct 85 ms 9952 KB Output is correct
3 Correct 92 ms 10484 KB Output is correct
4 Correct 72 ms 9852 KB Output is correct
5 Correct 73 ms 9296 KB Output is correct
6 Correct 75 ms 10192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 9388 KB Output is correct
2 Correct 66 ms 9812 KB Output is correct
3 Correct 83 ms 9812 KB Output is correct
4 Correct 88 ms 9568 KB Output is correct
5 Correct 98 ms 9808 KB Output is correct
6 Correct 86 ms 10176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 9444 KB Output is correct
2 Correct 99 ms 9796 KB Output is correct
3 Correct 77 ms 9844 KB Output is correct
4 Correct 98 ms 9976 KB Output is correct
5 Correct 88 ms 9644 KB Output is correct
6 Correct 65 ms 10188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 9736 KB Output is correct
2 Correct 65 ms 9236 KB Output is correct
3 Correct 66 ms 10704 KB Output is correct
4 Correct 76 ms 9652 KB Output is correct
5 Correct 80 ms 9808 KB Output is correct
6 Correct 87 ms 10956 KB Output is correct