# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
224395 | 2020-04-17T18:45:31 Z | PedroBigMan | Birmingham (COCI20_birmingham) | C++14 | 166 ms | 30944 KB |
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <map> #include <set> #include <queue> #include <deque> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=a; i<b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define INF 100000000000000000LL ll insig; #define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);} void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;} class Graph { public: ll N; vector<vector<ll> > adj; vector<bool> visited; //for DFS/BFS Graph(vector<vector<ll> > ad) { adj=ad; N=adj.size(); REP(i,0,N) {visited.pb(false);} } vector<ll> BFS(ll s) { vector<ll> distance; REP(i,0,N) {distance.pb(INF);} REP(i,0,N) {visited[i]=false;} distance[s]=0; visited[s]=true; deque<ll> d; d.pb(s); ll cur; while(!d.empty()) { cur=d.front(); d.pop_front(); REP(i,0,adj[cur].size()) { if(!visited[adj[cur][i]]) { visited[adj[cur][i]]=true; d.pb(adj[cur][i]); distance[adj[cur][i]]=distance[cur]+1; } } } return distance; } }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll N,M,Q,K; cin>>N>>M>>Q>>K; vector<ll> q; In(q,Q); REP(i,0,Q) {q[i]--;} vector<ll> xx; vector<vector<ll> > adj; REP(i,0,N) {adj.pb(xx);} pl cur; REP(i,0,M) { cin>>cur.ff>>cur.ss; cur.ff--; cur.ss--; adj[cur.ff].pb(cur.ss); adj[cur.ss].pb(cur.ff); } REP(i,1,q.size()) { REP(j,0,adj[q[i]].size()) {adj[q[0]].pb(adj[q[i]][j]);} } Graph G(adj); vector<ll> d=G.BFS(q[0]); vector<ll> ans; REP(i,0,N) {ans.pb(0LL);} REP(i,0,N) { /*ans[i]=(ll) sqrt(K*K+8LL*K*d[i]); ans[i]+=(K-1LL); ans[i]/=(2LL*K); */ REP(day,0,INF) {if((K*day*(day+1LL))/2LL>=d[i]) {ans[i]=day; break;}} } REP(i,0,q.size()) {ans[q[i]]=0LL;} REP(i,0,N) {cout<<ans[i]<<" ";} cout<<endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 8 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 129 ms | 20836 KB | Output is correct |
2 | Correct | 147 ms | 21860 KB | Output is correct |
3 | Correct | 160 ms | 28976 KB | Output is correct |
4 | Correct | 120 ms | 21600 KB | Output is correct |
5 | Correct | 125 ms | 22112 KB | Output is correct |
6 | Correct | 166 ms | 30944 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 137 ms | 21728 KB | Output is correct |
2 | Correct | 142 ms | 21348 KB | Output is correct |
3 | Correct | 152 ms | 26980 KB | Output is correct |
4 | Correct | 147 ms | 24164 KB | Output is correct |
5 | Correct | 136 ms | 23520 KB | Output is correct |
6 | Correct | 134 ms | 28520 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 133 ms | 21088 KB | Output is correct |
2 | Correct | 147 ms | 21808 KB | Output is correct |
3 | Correct | 152 ms | 28264 KB | Output is correct |
4 | Correct | 151 ms | 24112 KB | Output is correct |
5 | Correct | 134 ms | 22496 KB | Output is correct |
6 | Correct | 133 ms | 28520 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 117 ms | 20196 KB | Output is correct |
2 | Correct | 138 ms | 23396 KB | Output is correct |
3 | Correct | 147 ms | 27072 KB | Output is correct |
4 | Correct | 139 ms | 22796 KB | Output is correct |
5 | Correct | 124 ms | 22116 KB | Output is correct |
6 | Correct | 130 ms | 28008 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 117 ms | 20320 KB | Output is correct |
2 | Correct | 139 ms | 20832 KB | Output is correct |
3 | Correct | 137 ms | 25316 KB | Output is correct |
4 | Correct | 137 ms | 22628 KB | Output is correct |
5 | Correct | 128 ms | 22880 KB | Output is correct |
6 | Correct | 124 ms | 27748 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 137 ms | 20320 KB | Output is correct |
2 | Correct | 129 ms | 20964 KB | Output is correct |
3 | Correct | 128 ms | 26212 KB | Output is correct |
4 | Correct | 140 ms | 23396 KB | Output is correct |
5 | Correct | 120 ms | 22496 KB | Output is correct |
6 | Correct | 135 ms | 28520 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 128 ms | 20584 KB | Output is correct |
2 | Correct | 114 ms | 19940 KB | Output is correct |
3 | Correct | 162 ms | 27880 KB | Output is correct |
4 | Correct | 123 ms | 22372 KB | Output is correct |
5 | Correct | 127 ms | 23136 KB | Output is correct |
6 | Correct | 151 ms | 30812 KB | Output is correct |