Submission #1078233

#TimeUsernameProblemLanguageResultExecution timeMemory
1078233Marco_EscandonSeptember (APIO24_september)C++17
100 / 100
151 ms23036 KiB
//#include "september.h" #include <bits/stdc++.h> using namespace std; typedef int ll; #define x first #define y second vector<ll> temp,p; vector<vector<ll>> G; ll dfs(ll node) { ll asd=temp[node]; for(auto i:G[node]) asd=max(asd,dfs(i)); p[node]=asd; return asd; } vector<ll> calc(ll n, vector<ll> cad) { for(int i=0; i<cad.size(); i++) temp[cad[i]]=i; dfs(0); return p; } int solve(int n, int m, std::vector<int> F, std::vector<std::vector<int>> S) { G.clear();temp.clear();p.clear(); G.resize(n+2);temp.resize(n+2);p.resize(n+2); for(int i=1; i<n; i++) G[F[i]].push_back(i); vector<vector<ll>> cad(m); vector<ll> last(n+2); for(int i=0; i<m; i++) { cad[i]=calc(n,S[i]); for(int j=0; j<S[i].size(); j++) { last[S[i][j]]=max(j,last[S[i][j]]); } } ll a=-1,cont=0; for(int i=0; i<S[0].size(); i++) { if(i>a) cont++; for(int j=0; j<m; j++) { a=max(cad[j][S[j][i]],a); a=max(last[S[j][i]] ,a); } } return cont; }

Compilation message (stderr)

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