Submission #283320

#TimeUsernameProblemLanguageResultExecution timeMemory
283320davi_bartToy Train (IOI17_train)C++14
15 / 100
2081 ms1408 KiB
#include <bits/stdc++.h> #include "train.h" using namespace std; #define ll long long //#define int ll mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); bool pers[6000]; set<int> charge; vector<int> p[6000]; vector<int> tempo(5010,0); int temp=1; int dfs(int pos,int last_charge){//return 0 if cycle without charger if(tempo[pos]>0){ if(tempo[pos]>last_charge)return 0; return 1; } tempo[pos]=temp; if(charge.find(pos)!=charge.end())last_charge=temp; temp++; if(pers[pos]==0){ int sol=1; for(int x:p[pos]){ temp=tempo[pos]+1; sol=min(sol,dfs(x,last_charge)); } tempo[pos]=0; return sol; }else{ int sol=0; for(int x:p[pos]){ temp=tempo[pos]+1; sol=max(sol,dfs(x,last_charge)); } tempo[pos]=0; return sol; } } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { for(int i=0;i<a.size();i++)if(a[i])pers[i]=1; for(int i=0;i<r.size();i++)if(r[i])charge.insert(i); vector<int> ans(a.size(),0); for(int i=0;i<u.size();i++)p[u[i]].push_back(v[i]); for(int i=0;i<a.size();i++){ temp=1; fill(tempo.begin(),tempo.end(),0); ans[i]=dfs(i,-2); } return ans; }

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:39:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i=0;i<a.size();i++)if(a[i])pers[i]=1;
      |              ~^~~~~~~~~
train.cpp:40:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for(int i=0;i<r.size();i++)if(r[i])charge.insert(i);
      |              ~^~~~~~~~~
train.cpp:42:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i=0;i<u.size();i++)p[u[i]].push_back(v[i]);
      |              ~^~~~~~~~~
train.cpp:43:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for(int i=0;i<a.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...