답안 #224394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224394 2020-04-17T18:40:23 Z PedroBigMan Birmingham (COCI20_birmingham) C++14
15 / 70
167 ms 21856 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(i,0,q.size()) {ans[q[i]]=0LL;}
    REP(i,0,N) {cout<<ans[i]<<" ";}
    cout<<endl;
    return 0;
}

Compilation message

birmingham.cpp: In function 'void Out(std::vector<long long int>)':
birmingham.cpp:14:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
birmingham.cpp:23:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
birmingham.cpp:23:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
birmingham.cpp: In member function 'std::vector<long long int> Graph::BFS(ll)':
birmingham.cpp:14:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
birmingham.cpp:46:17:
             REP(i,0,adj[cur].size())
                 ~~~~~~~~~~~~~~~~~~~
birmingham.cpp:46:13: note: in expansion of macro 'REP'
             REP(i,0,adj[cur].size())
             ^~~
birmingham.cpp: In function 'int main()':
birmingham.cpp:14:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
birmingham.cpp:73:9:
     REP(i,1,q.size())
         ~~~~~~~~~~~~             
birmingham.cpp:73:5: note: in expansion of macro 'REP'
     REP(i,1,q.size())
     ^~~
birmingham.cpp:14:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
birmingham.cpp:75:13:
         REP(j,0,adj[q[i]].size()) {adj[q[0]].pb(adj[q[i]][j]);}
             ~~~~~~~~~~~~~~~~~~~~ 
birmingham.cpp:75:9: note: in expansion of macro 'REP'
         REP(j,0,adj[q[i]].size()) {adj[q[0]].pb(adj[q[i]][j]);}
         ^~~
birmingham.cpp:14:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
birmingham.cpp:86:9:
     REP(i,0,q.size()) {ans[q[i]]=0LL;}
         ~~~~~~~~~~~~             
birmingham.cpp:86:5: note: in expansion of macro 'REP'
     REP(i,0,q.size()) {ans[q[i]]=0LL;}
     ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 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 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 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 20836 KB Output is correct
2 Incorrect 142 ms 21732 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 21600 KB Output is correct
2 Incorrect 137 ms 21348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 167 ms 21076 KB Output is correct
2 Incorrect 145 ms 21856 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 120 ms 20156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 20304 KB Output is correct
2 Incorrect 134 ms 20936 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 20296 KB Output is correct
2 Incorrect 132 ms 20960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 20704 KB Output is correct
2 Incorrect 114 ms 20064 KB Output isn't correct
3 Halted 0 ms 0 KB -