Submission #1010363

#TimeUsernameProblemLanguageResultExecution timeMemory
1010363pccSeptember (APIO24_september)C++17
100 / 100
110 ms15428 KiB
#include "september.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int mxn = 1e5+10; int N,M; vector<int> tree[mxn]; bitset<mxn> vis; int cnt; void init(){ for(int i = 0;i<N;i++){ vis[i] = false; tree[i].clear(); } cnt = 0; } void dfs(int now){ if(vis[now])return; cnt += (vis[now] = 1); for(auto nxt:tree[now]){ if(!vis[nxt])dfs(nxt); } return; } int solve(int NN, int MM, std::vector<int> F, std::vector<std::vector<int>> S) { init(); N = NN; M = MM; for(int i = 1;i<N;i++)tree[F[i]].push_back(i); int ans = 0; for(int i = 0;i<S[0].size();i++){ for(int j = 0;j<M;j++)dfs(S[j][i]); if(cnt == i+1)ans++; } return ans; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i = 0;i<S[0].size();i++){
      |                ~^~~~~~~~~~~~
#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...