제출 #45310

#제출 시각아이디문제언어결과실행 시간메모리
45310imaxblue새로운 문제 (POI13_luk)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define x first #define y second #define pii pair<int, int> #define p3i pair<pii, int> #define pll pair<ll, ll> #define p3l pair<pll, ll> #define vi vector<int> #define vpii vector<pii> #define vp3i vector<p3i> #define vpll vector<pll> #define vp3l vector<p3l>#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define x first #define y second #define pii pair<int, int> #define p3i pair<pii, int> #define pll pair<ll, ll> #define p3l pair<pll, ll> #define vi vector<int> #define vpii vector<pii> #define vp3i vector<p3i> #define vpll vector<pll> #define vp3l vector<p3l> #define lseg L, (L+R)/2, N*2+1 #define rseg (L+R)/2+1, R, N*2+2 #define ub upper_bound #define lb lower_bound #define pq priority_queue #define MN 1000000007 #define fox(k, x) for (int k=0; k<x; ++k) #define fox1(k, x) for (int k=1; k<=x; ++k) #define foxr(k, x) for (int k=x-1; k>=0; --k) #define fox1r(k, x) for (int k=x; k>0; --k) #define ms multiset #define flood(x) memset(x, 0x3f3f3f3f, sizeof x) #define drain(x) memset(x, 0, sizeof x) #define rng() ((rand() << 14)+rand()) #define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0) char _; #define pi 3.14159265358979323846 #define siz(x) int(x.size()) #define int ll int n, x, y, lo, mid, hi=300000; vector<int> v[300005]; bool dfs(int N, ll D, int P){ D=D+mid-siz(v[N])+(P!=-1); if (D<0) return 0; fox(l, v[N].size()){ if (v[N][l]==P) continue; if (!dfs(v[N][l], D, N)) return 0; } return 1; } int32_t main(){ scanf("%lli", &n); fox(l, n-1){ scanf("%lli%lli", &x, &y); v[x].pb(y); v[y].pb(x); } while(lo<hi){ mid=(lo+hi)/2; if (dfs(1, 0, -1)) hi=mid; else lo=mid+1; } mid=150000; //cout << dfs(1, 0, -1) << endl; cout << lo; return 0; } #define lseg L, (L+R)/2, N*2+1 #define rseg (L+R)/2+1, R, N*2+2 #define ub upper_bound #define lb lower_bound #define pq priority_queue #define MN 1000000007 #define fox(k, x) for (int k=0; k<x; ++k) #define fox1(k, x) for (int k=1; k<=x; ++k) #define foxr(k, x) for (int k=x-1; k>=0; --k) #define fox1r(k, x) for (int k=x; k>0; --k) #define ms multiset #define flood(x) memset(x, 0x3f3f3f3f, sizeof x) #define drain(x) memset(x, 0, sizeof x) #define rng() ((rand() << 14)+rand()) #define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0) char _; #define pi 3.14159265358979323846 #define siz(x) int(x.size()) int n, x, y, lo, mid, hi=300000, cnt[300005]; vector<int> v[300005]; bool dfs(int N, int D, int P){ fox(l, v[N].size()){ if (v[N][l]==P) continue; dfs(v[N][l], D+1, N); } cnt[D]++; return 1; } int32_t main(){ scanf("%i", &n); fox(l, n-1){ scanf("%i%i", &x, &y); v[x].pb(y); v[y].pb(x); } dfs(1, 0, -1); fox1(l, n) lo=max(lo, cnt[l]); //cout << dfs(1, 0, -1) << endl; cout << lo; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

luk.cpp:31:0: warning: "vp3l" redefined
 #define vp3l vector<p3l>
 
luk.cpp:16:0: note: this is the location of the previous definition
 #define vp3l vector<p3l>#include <bits/stdc++.h>
 
luk.cpp: In function 'bool dfs(long long int, long long int, long long int)':
luk.cpp:18:12: error: expected primary-expression before 'long'
 #define ll long long
            ^
luk.cpp:50:13: note: in expansion of macro 'll'
 #define int ll
             ^~
luk.cpp:49:16: note: in expansion of macro 'int'
 #define siz(x) int(x.size())
                ^~~
luk.cpp:55:13: note: in expansion of macro 'siz'
     D=D+mid-siz(v[N])+(P!=-1);
             ^~~
luk.cpp:38:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
luk.cpp:57:9:
     fox(l, v[N].size()){
         ~~~~~~~~~~~~~~            
luk.cpp:57:5: note: in expansion of macro 'fox'
     fox(l, v[N].size()){
     ^~~
luk.cpp: At global scope:
luk.cpp:96:6: error: redefinition of 'char _'
 char _;
      ^
luk.cpp:47:6: note: 'char _' previously declared here
 char _;
      ^
luk.cpp:100:5: error: redefinition of 'long long int n'
 int n, x, y, lo, mid, hi=300000, cnt[300005];
     ^
luk.cpp:52:5: note: 'long long int n' previously declared here
 int n, x, y, lo, mid, hi=300000;
     ^
luk.cpp:21:11: error: redefinition of 'long long int first'
 #define x first
           ^
luk.cpp:100:8: note: in expansion of macro 'x'
 int n, x, y, lo, mid, hi=300000, cnt[300005];
        ^
luk.cpp:21:11: note: 'long long int first' previously declared here
 #define x first
           ^
luk.cpp:52:8: note: in expansion of macro 'x'
 int n, x, y, lo, mid, hi=300000;
        ^
luk.cpp:22:11: error: redefinition of 'long long int second'
 #define y second
           ^
luk.cpp:100:11: note: in expansion of macro 'y'
 int n, x, y, lo, mid, hi=300000, cnt[300005];
           ^
luk.cpp:22:11: note: 'long long int second' previously declared here
 #define y second
           ^
luk.cpp:52:11: note: in expansion of macro 'y'
 int n, x, y, lo, mid, hi=300000;
           ^
luk.cpp:100:14: error: redefinition of 'long long int lo'
 int n, x, y, lo, mid, hi=300000, cnt[300005];
              ^~
luk.cpp:52:14: note: 'long long int lo' previously declared here
 int n, x, y, lo, mid, hi=300000;
              ^~
luk.cpp:100:18: error: redefinition of 'long long int mid'
 int n, x, y, lo, mid, hi=300000, cnt[300005];
                  ^~~
luk.cpp:52:18: note: 'long long int mid' previously declared here
 int n, x, y, lo, mid, hi=300000;
                  ^~~
luk.cpp:100:23: error: redefinition of 'long long int hi'
 int n, x, y, lo, mid, hi=300000, cnt[300005];
                       ^~
luk.cpp:52:23: note: 'long long int hi' previously defined here
 int n, x, y, lo, mid, hi=300000;
                       ^~
luk.cpp:101:21: error: redefinition of 'std::vector<long long int> v [300005]'
 vector<int> v[300005];
                     ^
luk.cpp:53:13: note: 'std::vector<long long int> v [300005]' previously declared here
 vector<int> v[300005];
             ^
luk.cpp: In function 'bool dfs(long long int, long long int, long long int)':
luk.cpp:102:6: error: redefinition of 'bool dfs(long long int, long long int, long long int)'
 bool dfs(int N, int D, int P){
      ^~~
luk.cpp:54:6: note: 'bool dfs(long long int, long long int, long long int)' previously defined here
 bool dfs(int N, ll D, int P){
      ^~~
luk.cpp:87:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
luk.cpp:103:9:
     fox(l, v[N].size()){
         ~~~~~~~~~~~~~~            
luk.cpp:103:5: note: in expansion of macro 'fox'
     fox(l, v[N].size()){
     ^~~
luk.cpp: In function 'int32_t main()':
luk.cpp:110:9: error: redefinition of 'int32_t main()'
 int32_t main(){
         ^~~~
luk.cpp:63:9: note: 'int32_t main()' previously defined here
 int32_t main(){
         ^~~~
luk.cpp:111:19: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
     scanf("%i", &n);
                 ~~^
luk.cpp:113:29: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%i%i", &x, &y);
                             ^
luk.cpp:113:29: warning: format '%i' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
luk.cpp: In function 'int32_t main()':
luk.cpp:64:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lli", &n);
     ~~~~~^~~~~~~~~~~~
luk.cpp:66:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lli%lli", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~
luk.cpp: In function 'int32_t main()':
luk.cpp:111:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i", &n);
     ~~~~~^~~~~~~~~~
luk.cpp:113:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~