제출 #938769

#제출 시각아이디문제언어결과실행 시간메모리
938769AdamGS참나무 (IOI23_beechtree)C++17
0 / 100
33 ms9556 KiB
#include "beechtree.h" #include<bits/stdc++.h> using namespace std; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=2e3+7; vector<pair<int,int>>V[LIM], K; vector<int>S[LIM]; int ile[LIM]; bool ok; void DFS(int x) { ile[x]=1; for(auto i : V[x]) { DFS(i.nd); ile[x]+=ile[i.nd]; } } void DFS2(int x) { for(int i=1; i<V[x].size(); ++i) if(V[x][i].st==V[x][i-1].st) ok=false; S[ile[x]].pb(x); K.pb({ile[x], x}); for(auto i : V[x]) DFS2(i.nd); } bool comp(int a, int b) { if(V[a].size()!=V[b].size()) return false; rep(i, V[a].size()) { if(V[a][i].st!=V[b][i].st) return false; if(ile[V[a][i].nd]!=ile[V[b][i].nd]) return false; } return true; } bool zawiera(int a, int b) { if(V[a].size()>V[b].size()) return false; int l=0; rep(i, V[a].size()) { while(l<V[b].size() && V[b][l].st!=V[a][i].st) ++l; if(l==V[b].size()) return false; } return true; } vector<int>beechtree(int n, int m, vector<int>P, vector<int>C) { rep(i, n-1) V[P[i+1]].pb({C[i+1], i+1}); rep(i, n) sort(all(V[i])); DFS(0); vector<int>ans(n); rep(i, n) { K.clear(); ok=true; rep(j, n) S[j+1].clear(); DFS2(i); sort(all(K)); rep(j, n) { for(int l=1; l<S[j+1].size(); ++l) if(!comp(S[j+1][l-1], S[j+1][l])) ok=false; } for(int j=1; j<K.size(); ++j) if(!zawiera(K[j-1].nd, K[j].nd)) ok=false; if(ok) ans[i]=1; } return ans; }

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

beechtree.cpp: In function 'void DFS2(int)':
beechtree.cpp:22:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int i=1; i<V[x].size(); ++i) if(V[x][i].st==V[x][i-1].st) ok=false;
      |                ~^~~~~~~~~~~~
beechtree.cpp: In function 'bool comp(int, int)':
beechtree.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
beechtree.cpp:29:3: note: in expansion of macro 'rep'
   29 |   rep(i, V[a].size()) {
      |   ^~~
beechtree.cpp: In function 'bool zawiera(int, int)':
beechtree.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
beechtree.cpp:38:3: note: in expansion of macro 'rep'
   38 |   rep(i, V[a].size()) {
      |   ^~~
beechtree.cpp:39:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     while(l<V[b].size() && V[b][l].st!=V[a][i].st) ++l;
      |           ~^~~~~~~~~~~~
beechtree.cpp:40:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     if(l==V[b].size()) return false;
      |        ~^~~~~~~~~~~~~
beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:56:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |       for(int l=1; l<S[j+1].size(); ++l) if(!comp(S[j+1][l-1], S[j+1][l])) ok=false;
      |                    ~^~~~~~~~~~~~~~
beechtree.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int j=1; j<K.size(); ++j) if(!zawiera(K[j-1].nd, K[j].nd)) ok=false;
      |                  ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...