답안 #99735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99735 2019-03-06T11:13:45 Z kjp4155 Unique Cities (JOI19_ho_t5) C++17
4 / 100
202 ms 640 KB
#include <bits/stdc++.h>

using namespace std;

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define Debug1(a)           cout<<#a<<"="<<(a)<<"\n"
#define Debug2(a,b)         cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define Debug3(a,b,c)       cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define Debug4(a,b,c,d)     cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define Debug5(a,b,c,d,e)   cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define Debug6(a,b,c,d,e,f) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define Debug(...) macro_dispatcher(Debug, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,s,n) cout<<#a<<"=["; printarray(a,s,n); cout<<"]\n"

#define TT1 template<class T>
#define TT1T2 template<class T1, class T2>
#define TT1T2T3 template<class T1, class T2, class T3>
template<class T, size_t N> ostream& operator << (ostream& os, const array<T, N>& v);
TT1T2 ostream& operator << (ostream& os, const pair<T1, T2>& p){ return os <<"("<<p.first<<", "<< p.second<<")"; }
TT1 ostream& operator << (ostream& os, const vector<T>& v){       bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
template<class T, size_t N> ostream& operator << (ostream& os, const array<T, N>& v) {     bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const set<T1, T2>&v){    bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const multiset<T1,T2>&v){bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2T3 ostream& operator << (ostream& os, const map<T1,T2,T3>& v){ bool f = 1; os << "["; for (auto& ii : v) { if (!f)os << ", "; os << "(" << ii.first << " -> " << ii.second << ") "; f = 0; }return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const multimap<T1, T2>& v){ bool f = 1; os << "["; for (auto& ii : v) { if (!f)os << ", "; os << "(" << ii.first << " -> " << ii.second << ") "; f = 0; }return os << "]"; }
TT1T2 ostream& operator << (ostream& os, priority_queue<T1, T2> v) { bool f = 1; os << "["; while (!v.empty()) { auto x = v.top(); v.pop(); if (!f) os << ", "; f = 0; os << x; } return os << "]"; }
TT1T2 void printarray(const T1& a, T2 l, T2 r){ for (T2 i = l; i<=r; i++) cout << a[i] << (i<r?" ":""); }

void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(15);
}

#define tt() printf("%.4f sec\n", (double) clock() / CLOCKS_PER_SEC )

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()
#define geti1(X) cin >> X
#define geti2(X,Y) cin >> X >> Y
#define geti3(X,Y,Z) cin >> X >> Y >> Z
#define geti4(X,Y,Z,W) cin >> X >> Y >> Z >> W
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define endl '\n'

typedef tuple<int,int,int> t3;
typedef tuple<int,int,int,int> t4;
void die(){printf("-1\n"); exit(0);}
int xx[8] = {1,-1,0,0,1,1,-1,-1}, yy[8] = {0,0,1,-1,1,-1,1,-1};
const ll mod = 1e9+7;

pii operator + (pii a, pii b){
    return pii(a.Fi+b.Fi, a.Se+b.Se);
}
#define MAXN 2200
int N,M;
vector<int> E[MAXN];
int C[MAXN], ans[MAXN];
int D[MAXN], vis[MAXN];
void dfs(int x, int d){
    vis[x] = 1;
    if( d > 0 ){
        if( D[d] != 0 ) D[d] = -1;
        else D[d] = C[x];
    }
    for(auto e : E[x])if( !vis[e] ) dfs(e, d+1);
}

int main(){
    scanf("%d%d",&N,&M);
    repp(i,N-1){
        int a,b; scanf("%d%d",&a,&b);
        E[a].pb(b); E[b].pb(a);
    }
    repp(i,N) scanf("%d",&C[i]);

    repp(i,N){
        memset(vis,0,sizeof vis);
        repp(i,N) D[i] = 0;
        dfs(i, 0);
        vector<int> v;
        repp(i,N) if( D[i] > 0 ) v.push_back(D[i]);
        sort(all(v)); v.erase(unique(all(v)), v.end());
        printf("%d\n",sz(v));
    }
}

Compilation message

joi2019_ho_t5.cpp: In function 'int main()':
joi2019_ho_t5.cpp:88:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&M);
     ~~~~~^~~~~~~~~~~~~~
joi2019_ho_t5.cpp:90:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int a,b; scanf("%d%d",&a,&b);
                  ~~~~~^~~~~~~~~~~~~~
joi2019_ho_t5.cpp:93:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     repp(i,N) scanf("%d",&C[i]);
               ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 56 ms 492 KB Output is correct
3 Correct 39 ms 484 KB Output is correct
4 Correct 106 ms 532 KB Output is correct
5 Correct 78 ms 512 KB Output is correct
6 Correct 153 ms 584 KB Output is correct
7 Correct 85 ms 604 KB Output is correct
8 Correct 64 ms 500 KB Output is correct
9 Correct 104 ms 500 KB Output is correct
10 Correct 109 ms 500 KB Output is correct
11 Correct 89 ms 512 KB Output is correct
12 Correct 52 ms 512 KB Output is correct
13 Correct 138 ms 568 KB Output is correct
14 Correct 94 ms 520 KB Output is correct
15 Correct 96 ms 520 KB Output is correct
16 Correct 30 ms 512 KB Output is correct
17 Correct 96 ms 604 KB Output is correct
18 Correct 65 ms 512 KB Output is correct
19 Correct 68 ms 384 KB Output is correct
20 Correct 202 ms 632 KB Output is correct
21 Correct 92 ms 536 KB Output is correct
22 Correct 63 ms 512 KB Output is correct
23 Correct 77 ms 500 KB Output is correct
24 Correct 72 ms 548 KB Output is correct
25 Correct 91 ms 512 KB Output is correct
26 Correct 50 ms 632 KB Output is correct
27 Correct 155 ms 572 KB Output is correct
28 Correct 106 ms 640 KB Output is correct
29 Correct 91 ms 556 KB Output is correct
30 Correct 35 ms 512 KB Output is correct
31 Correct 129 ms 560 KB Output is correct
32 Correct 74 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 612 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 56 ms 492 KB Output is correct
3 Correct 39 ms 484 KB Output is correct
4 Correct 106 ms 532 KB Output is correct
5 Correct 78 ms 512 KB Output is correct
6 Correct 153 ms 584 KB Output is correct
7 Correct 85 ms 604 KB Output is correct
8 Correct 64 ms 500 KB Output is correct
9 Correct 104 ms 500 KB Output is correct
10 Correct 109 ms 500 KB Output is correct
11 Correct 89 ms 512 KB Output is correct
12 Correct 52 ms 512 KB Output is correct
13 Correct 138 ms 568 KB Output is correct
14 Correct 94 ms 520 KB Output is correct
15 Correct 96 ms 520 KB Output is correct
16 Correct 30 ms 512 KB Output is correct
17 Correct 96 ms 604 KB Output is correct
18 Correct 65 ms 512 KB Output is correct
19 Correct 68 ms 384 KB Output is correct
20 Correct 202 ms 632 KB Output is correct
21 Correct 92 ms 536 KB Output is correct
22 Correct 63 ms 512 KB Output is correct
23 Correct 77 ms 500 KB Output is correct
24 Correct 72 ms 548 KB Output is correct
25 Correct 91 ms 512 KB Output is correct
26 Correct 50 ms 632 KB Output is correct
27 Correct 155 ms 572 KB Output is correct
28 Correct 106 ms 640 KB Output is correct
29 Correct 91 ms 556 KB Output is correct
30 Correct 35 ms 512 KB Output is correct
31 Correct 129 ms 560 KB Output is correct
32 Correct 74 ms 532 KB Output is correct
33 Runtime error 3 ms 612 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Halted 0 ms 0 KB -