제출 #439852

#제출 시각아이디문제언어결과실행 시간메모리
439852adamjinwei슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "supertrees.h" #define inf 1000000007 #define mod 1000000007 #define rnd() rand_num() #define bigrnd() dis(rand_num) //#pragma GCC optimize("Ofast","inline","-ffast-math") //#pragma GCC target("avx,sse2,sse3,sse4,mmx") //#define int long long using namespace std; unsigned sed=std::chrono::system_clock::now().time_since_epoch().count(); mt19937 rand_num(sed); uniform_int_distribution<long long> dis(0,inf); template <typename T> void read(T &x){ x=0;char ch=getchar();int fh=1; while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();} while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); x*=fh; } template <typename T> void write(T x) { if (x<0) x=-x,putchar('-'); if (x>9) write(x/10); putchar(x%10+'0'); } template <typename T> void writeln(T x) { write(x); puts(""); } int n; int fa[1005]; int g[1005][1005]; int fnd(int x) { if(fa[x]!=x) fa[x]=fnd(fa[x]); return fa[x]; } int construct(vector<vector<int>> p) { n=p.size(); for(int i=0;i<n;++i) fa[i]=i; for(int i=0;i<n;++i) for(int j=0;j<n;++j) if(p[i][j]==3) return 0; else if(p[i][j]!=0) fa[fnd(i)]=fnd(j); for(int i=0;i<n;++i) for(int j=0;j<n;++j) if(p[i][j]==0&&fnd(i)==fnd(j)) return 0; for(int i=0;i<n;++i) fa[i]=i; for(int i=0;i<n;++i) for(int j=0;j<n;++j) if(p[i][j]==1) fa[fnd(i)]=fnd(j); for(int i=0;i<n;++i) for(int j=0;j<n;++j) if(p[i][j]==2&&fnd(i)==fnd(j)) return 0; vector<int> vec; bool flag=false; for(int i=0;i<n;++i) if(fnd(i)==i) vec.push_back(i); for(int i=0;i<n;++i) for(int j=0;j<n;++j) if(p[i][j]==2) flag=true; if(flag&&vec.size()<3) return 0; if(flag) { for(int i=0;i+1<vec.size();++i) g[vec[i]][vec[i+1]]=g[vec[i+1]][vec[i]]=1; if(vec.size()>1) g[vec[0]][vec[vec.size()-1]]=g[vec[vec.size()-1]][vec[0]]=1; } for(int i=0;i<n;++i) if(fnd(i)!=i) g[fnd(i)][i]=g[i][fnd(i)]=1; vector<vector<int>> ans; for(int i=0;i<n;++i) { vector<int> tmp; for(int j=0;j<n;++j) tmp.push_back(g[i][j]); vec.push_back(tmp); } return ans; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:74:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |   for(int i=0;i+1<vec.size();++i)
      |               ~~~^~~~~~~~~~~
supertrees.cpp:87:20: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
   87 |   vec.push_back(tmp);
      |                    ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from supertrees.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
supertrees.cpp:89:9: error: cannot convert 'std::vector<std::vector<int> >' to 'int' in return
   89 |  return ans;
      |         ^~~