제출 #1183376

#제출 시각아이디문제언어결과실행 시간메모리
1183376mertbbmICC (CEOI16_icc)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "icc.h" using namespace std; //#define int long long #define ld long double #define show(x,y) cout << y << " " << #x << endl; #define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl; #define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl; #define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl; typedef pair<int,int>pii; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); struct DSU{ vector<int>e; void init(int n){ e=vector<int>(n,-1); } int get(int x){ return e[x]<0?x:e[x]=get(e[x]); } bool unite(int x, int y){ x=get(x); y=get(y); if(x==y) return 0; if(e[x]>e[y]) swap(x,y); e[x]+=e[y]; e[y]=x; return 1; } }; void run(int n){ DSU dsu; dsu.init(n+5); vector<int>bit={2,4,8,16,32,64,128}; for(int x=0;x<n-1;x++){ int layer=0; vector<int>a,b; vector<int>nodes; for(int y=1;y<=n;y++){ if(dsu.get(y)==y) nodes.push_back(y-1); } int need=lower_bound(bit.begin(),bit.end(),nodes.size())-bit.begin(); for(int y=0;y<=need;y++){ a.clear(); b.clear(); for(auto it:nodes){ if(it&(1<<y)) a.push_back(it+1); else b.push_back(it+1); } if(query(a.size(),b.size(),a,b)){ break; } } //decomp while(a.size()>1||b.size()>1){ //2 queries vector<int>a1,a2,b1,b2; for(int y=0;y<(int)a.size();y++){ if(y%2) a1.push_back(a[y]); else a2.push_back(a[y]); } for(int y=0;y<(int)b.size();y++){ if(y%2) b1.push_back(b[y]); else b2.push_back(b[y]); } bool hold=query(a1.size(),b.size(),a,b); if(hold){ hold=query(a1.size(),b1.size(),a1,b1); a=a1; if(hold){ b=b1; } else{ b=b2; } } else{ a=a2; hold=query(a2.size(),b1.size(),a2,b1); if(hold){ b=b1; } else b=b2; } } dsu.unite(a[0],b[0]); setRoad(a[0],b[0]); } }

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

icc.cpp: In function 'void run(int)':
icc.cpp:55:52: error: cannot convert 'std::vector<int>' to 'int*'
   55 |                         if(query(a.size(),b.size(),a,b)){
      |                                                    ^
      |                                                    |
      |                                                    std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:74:60: error: cannot convert 'std::vector<int>' to 'int*'
   74 |                         bool hold=query(a1.size(),b.size(),a,b);
      |                                                            ^
      |                                                            |
      |                                                            std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:76:64: error: cannot convert 'std::vector<int>' to 'int*'
   76 |                                 hold=query(a1.size(),b1.size(),a1,b1);
      |                                                                ^~
      |                                                                |
      |                                                                std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:87:64: error: cannot convert 'std::vector<int>' to 'int*'
   87 |                                 hold=query(a2.size(),b1.size(),a2,b1);
      |                                                                ^~
      |                                                                |
      |                                                                std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^