제출 #842435

#제출 시각아이디문제언어결과실행 시간메모리
842435arnold518참나무 (IOI23_beechtree)C++17
0 / 100
2076 ms48976 KiB
#include "beechtree.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5; int N, M; int P[MAXN+10], C[MAXN+10]; vector<int> adj[MAXN+10]; vector<pii> V[MAXN+10]; int ans[MAXN+10]; void dfs(int now) { for(int nxt : adj[now]) { V[C[nxt]].push_back({now, adj[nxt].size()==0}); dfs(nxt); } } vector<int> beechtree(int _N, int _M, vector<int> _P, vector<int> _C) { N=_N; M=_M; for(int i=1; i<=N; i++) P[i]=_P[i-1]+1, C[i]=_C[i-1]; for(int i=2; i<=N; i++) adj[P[i]].push_back(i); for(int i=1; i<=N; i++) { dfs(i); bool flag=true; sort(V+1, V+M+1, [&](const vector<pii> &p, const vector<pii> &q) { return p.size()<q.size(); }); for(int j=1; j<=M; j++) { sort(V[j].begin(), V[j].end()); for(int k=0; k+1<V[j].size(); k++) if(V[j][k].first==V[j][k+1].first) flag=false; } if(flag) { for(int j=2; j<=M; j++) { bool f1=0, f2=0; int p=0, q=0; for(; p<V[j].size(); p++) { if(q<V[j-1].size() && V[j-1][q].first==V[j][p].first) { if(V[j][p].second) f1=1; q++; } else { if(!V[j][p].second) f2=1; } } if(q!=V[j-1].size()) flag=false; if(f1 && f2) flag=false; } } ans[i]=flag; for(int j=1; j<=M; j++) V[j].clear(); } return vector<int>(ans+1, ans+N+1); }

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

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:44:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for(int k=0; k+1<V[j].size(); k++) if(V[j][k].first==V[j][k+1].first) flag=false;
      |                          ~~~^~~~~~~~~~~~
beechtree.cpp:52:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                 for(; p<V[j].size(); p++)
      |                       ~^~~~~~~~~~~~
beechtree.cpp:54:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |                     if(q<V[j-1].size() && V[j-1][q].first==V[j][p].first)
      |                        ~^~~~~~~~~~~~~~
beechtree.cpp:64:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |                 if(q!=V[j-1].size()) flag=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...