Submission #569515

# Submission time Handle Problem Language Result Execution time Memory
569515 2022-05-27T12:52:27 Z NemanjaSo2005 Werewolf (IOI18_werewolf) C++14
15 / 100
4000 ms 41308 KB
#include "werewolf.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll N,M,Q,prosli[200005],pos[200005],pvred;
vector<int> graf[200005],ret;
struct kveri{
   int poc,kraj,id;
   ll L,R;
} upiti[200005];
void dfs(int gde,int L,int R){
  // cout<<"DFS sa "<<pvred<<" u "<<gde<<endl;
   prosli[gde]=pvred;
   pos[gde]++;
   for(int i=0;i<graf[gde].size();i++){
      if(prosli[graf[gde][i]]==pvred)
         continue;
      //cout<<graf[gde][i]<<" "<<L<<" "<<R<<endl;
      if(graf[gde][i]<L)
         continue;
      if(graf[gde][i]>R)
         continue;
     // cout<<"DALJE"<<endl;
      dfs(graf[gde][i],L,R);
   }
}
vector<int> check_validity(int NN, vector<int> X, vector<int> Y,vector<int> S, vector<int> E,vector<int> L, vector<int> R) {
   N=NN;
   M=X.size();
   Q=L.size();
   ret.resize(Q);
   for(int i=0;i<M;i++){
      X[i]++;
      Y[i]++;
      graf[X[i]].push_back(Y[i]);
      graf[Y[i]].push_back(X[i]);
   }
   for(int i=0;i<Q;i++){
      S[i]++;
      E[i]++;
      L[i]++;
      R[i]++;
      upiti[i+1].id=i;
      upiti[i+1].poc=S[i];
      upiti[i+1].kraj=E[i];
      upiti[i+1].L=L[i];
      upiti[i+1].R=R[i];
   }
   if(N*Q<=10000000){
      for(int j=1;j<=Q;j++){
         for(int i=1;i<=N;i++)
            pos[i]=0;
         pvred++;
         dfs(upiti[j].poc,upiti[j].L,N);
        // for(int i=1;i<=N;i++)
         //   cout<<pos[i]<<" ";
         //cout<<endl;
         pvred++;
         dfs(upiti[j].kraj,1,upiti[j].R);
         //for(int i=1;i<=N;i++)
          //  cout<<pos[i]<<" ";
         //cout<<endl;
         ret[upiti[j].id]=0;
         for(int i=1;i<=N;i++)
            if(pos[i]==2)
               ret[upiti[j].id]=1;
      }
      return ret;
   }
}

Compilation message

werewolf.cpp: In function 'void dfs(int, int, int)':
werewolf.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |    for(int i=0;i<graf[gde].size();i++){
      |                ~^~~~~~~~~~~~~~~~~
werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
   70 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5016 KB Output is correct
5 Correct 3 ms 5012 KB Output is correct
6 Correct 4 ms 5012 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 4 ms 5016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5016 KB Output is correct
5 Correct 3 ms 5012 KB Output is correct
6 Correct 4 ms 5012 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 4 ms 5016 KB Output is correct
10 Correct 300 ms 5536 KB Output is correct
11 Correct 169 ms 5412 KB Output is correct
12 Correct 28 ms 5688 KB Output is correct
13 Correct 354 ms 5540 KB Output is correct
14 Correct 215 ms 5488 KB Output is correct
15 Correct 282 ms 5676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4035 ms 41308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5016 KB Output is correct
5 Correct 3 ms 5012 KB Output is correct
6 Correct 4 ms 5012 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 4 ms 5016 KB Output is correct
10 Correct 300 ms 5536 KB Output is correct
11 Correct 169 ms 5412 KB Output is correct
12 Correct 28 ms 5688 KB Output is correct
13 Correct 354 ms 5540 KB Output is correct
14 Correct 215 ms 5488 KB Output is correct
15 Correct 282 ms 5676 KB Output is correct
16 Execution timed out 4035 ms 41308 KB Time limit exceeded
17 Halted 0 ms 0 KB -