제출 #745559

#제출 시각아이디문제언어결과실행 시간메모리
745559almothana05통행료 (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; vector<pair<long long , long long> >kinder[300000] , ka; vector<long long>cent , ed; long long sub[300000], vis[300000]; long long a , b , menge , cmp , comp ,numm , nummer , kind; long long st , en , mid , mit; long long centroid(long long x , long long f , long long n){ for(long long i = 0 ; i < kinder[x].size() ; i++){ kind = kinder[x][i].first; if(vis[kind] != 2 &&kind != f && sub[kind] * 2 > n){ return centroid(kind , x , n); } } for(long long i = 0 ; i < kinder[x].size() ; i++){ ed[kinder[x][i].second] = 1; } vis[x] = 2; return x; } long long dfs(long long x){ vis[x] = 1; sub[x] = 1; for(long long i = 0 ; i < kinder[x].size() ; i++){ kind = kinder[x][i].first; if(vis[kind] == 0){ sub[x] += dfs(kind); } } return sub[x]; } long long bis(long long x , long long y , long long z ,long long f , long long root){ for(long long i = 0 ; i <= y ; i++){ ed[kinder[root][i].second] = 1; } st = x ; en = y; mid = y; while(st <= en){ mit = (st + en)/2; while(mid > mit){ if(kinder[root][mid].first == f){ mid--; continue; } ed[kinder[root][mid].second] = 0; mid--; } while(mid <= mit){ if(kinder[root][mid].first == f){ mid++; continue; } ed[kinder[root][mid].second] = 1; mid++; } if(mid > mit){ mid--; } numm = ask(ed); if(numm >= z){ en = mit - 1; } else{ st = mit + 1; } } return st; } long long suche(long long x){ dfs(x); numm = centroid(x ,x , sub[x]); // cout << x << ' '<<numm << "\n"; long long fater,pl; for(long long i = 0 ; i < kinder[numm].size() ; i++ ){ if(sub[kinder[numm][i].first] > sub[numm]){ fater = kinder[numm][i].first; break; } } cmp = ask(ed); if(numm == x){ if(cmp == comp){ return numm; } else{ comp = cmp; pl = bis(0 , kinder[numm].size() - 1 , cmp , fater , numm ); } } else{ if(cmp == comp){ return suche(x); } else if(cmp == comp + b - a){ return numm; } else{ comp = cmp; pl = bis(0 , kinder[numm].size() - 1 , cmp , fater , numm ); } } return suche(kinder[numm][pl].first); } void finde(){ for(long long i = 0 ; i < menge ; i++){ if(vis[i] == 0){ ka.push_back({i , dfs(i)}); } } for(long long i = 0 ; i < ka.size() ; i++){ cent.push_back(centroid(ka[i].first , ka[i].first , ka[i].second)); } for(long long i = 0 ; i < menge ; i++){ if(vis[i] == 1){ vis[i] = 0; } } ka.clear(); comp = ask(ed); if(comp > cmp){ st = 0 ; en = cent.size() - 2; mid = cent.size() - 1; while(st <= en){ mit = (st + en)/2; while(mid > mit){ for(long long i = 0 ; i < kinder[cent[mid]].size() ; i++){ ed[kinder[cent[mid]][i].second] = 0; } mid--; } while(mid <= mit){ for(long long i = 0 ; i < kinder[cent[mid]].size() ; i++){ ed[kinder[cent[mid]][i].second] = 1; } mid++; } if(mid > mit){ mid--; } numm = ask(ed); if(numm == comp){ en = mit - 1; } else{ st = mit + 1; } } long long root , er ,zw; root = cent[st]; cent.clear(); er = bis(0 , kinder[root].size() - 1 , cmp +b -a , -1 , root); // cout << er << "\n"; if(comp == cmp + b - a){ zw = root; for(long long i = 0 ; i < kinder[root].size() ; i++){ ed[kinder[root][i].second] = 1; } } else{ zw = bis(er , kinder[root].size() - 1 , comp , -1 , root); // cout << zw << "\n"; for(long long i = 0 ; i < kinder[root].size() ; i++){ ed[kinder[root][i].second] = 1; } // cout << kinder[root][er].first << "\n"; zw = suche(kinder[root][zw].first); } er = suche(kinder[root][er].first); answer(er , zw); return; } cent.clear(); finde(); } void find_pair(long long N, vector<long long> u, vector<long long> v, long long A, long long B) { a = A; b = B; menge = N; for(long long i = 0 ; i < u.size() ; i++){ kinder[u[i]].push_back({v[i] , i}); kinder[v[i]].push_back({u[i] , i}); ed.push_back(0); } cmp = ask(ed); finde(); }

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

highway.cpp: In function 'long long int centroid(long long int, long long int, long long int)':
highway.cpp:10:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for(long long i = 0 ; i < kinder[x].size() ; i++){
      |                         ~~^~~~~~~~~~~~~~~~~~
highway.cpp:16:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(long long i = 0 ; i < kinder[x].size() ; i++){
      |                         ~~^~~~~~~~~~~~~~~~~~
highway.cpp: In function 'long long int dfs(long long int)':
highway.cpp:25:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(long long i = 0 ; i < kinder[x].size() ; i++){
      |                         ~~^~~~~~~~~~~~~~~~~~
highway.cpp: In function 'long long int bis(long long int, long long int, long long int, long long int, long long int)':
highway.cpp:62:18: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   62 |       numm = ask(ed);
      |                  ^~
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp: In function 'long long int suche(long long int)':
highway.cpp:77:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |   for(long long i = 0 ; i < kinder[numm].size() ; i++ ){
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
highway.cpp:83:13: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   83 |   cmp = ask(ed);
      |             ^~
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp: In function 'void finde()':
highway.cpp:115:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  115 |   for(long long i = 0 ; i < ka.size() ; i++){
      |                         ~~^~~~~~~~~~~
highway.cpp:124:14: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
  124 |   comp = ask(ed);
      |              ^~
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp:131:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  131 |           for(long long i = 0 ; i < kinder[cent[mid]].size() ; i++){
      |                                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
highway.cpp:139:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |           for(long long i = 0 ; i < kinder[cent[mid]].size() ; i++){
      |                                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
highway.cpp:148:18: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
  148 |       numm = ask(ed);
      |                  ^~
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp:163:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  163 |       for(long long i = 0 ; i < kinder[root].size() ; i++){
      |                             ~~^~~~~~~~~~~~~~~~~~~~~
highway.cpp:170:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  170 |       for(long long i = 0 ; i < kinder[root].size() ; i++){
      |                             ~~^~~~~~~~~~~~~~~~~~~~~
highway.cpp: In function 'void find_pair(long long int, std::vector<long long int>, std::vector<long long int>, long long int, long long int)':
highway.cpp:188:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  188 |   for(long long i = 0 ; i < u.size() ; i++){
      |                         ~~^~~~~~~~~~
highway.cpp:193:13: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
  193 |   cmp = ask(ed);
      |             ^~
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^