Submission #829780

# Submission time Handle Problem Language Result Execution time Memory
829780 2023-08-18T14:59:24 Z NemanjaSo2005 Stray Cat (JOI20_stray) C++17
91 / 100
46 ms 17056 KB
#include "Anthony.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<int> graf[20005];
int dist[20005],sta[20005];
queue<int> Q;
string E;
int N;
bool prosli[20005];
void BFS(int gde){
   for(int i=0;i<=N;i++)
      dist[i]=-1;
   dist[gde]=0;
   Q.push(gde);
   while(Q.size()){
      int tren=Q.front();
      Q.pop();
      if(prosli[tren])
         continue;
      //cout<<tren<<endl;
      prosli[tren]=true;
      for(int i=0;i<graf[tren].size();i++)
         if(dist[graf[tren][i]]==-1){
            dist[graf[tren][i]]=dist[tren]+1;
            Q.push(graf[tren][i]);
         }
   }
   return;
}
void dfs2(int gde,int pret,int cyc){
   if(gde==pret){
      for(int i=0;i<graf[gde].size();i++){
         dfs2(graf[gde][i],gde,0);
      }
      return;
   }
  // cout<<gde<<" "<<cyc<<endl;
   if(cyc==16)
      sta[gde]=0;
   if(cyc==32)
      sta[gde]=1;
   if(cyc<=5)
      sta[gde]=E[cyc]-'0';
   if(graf[gde].size()>2){
      if(sta[gde]==1)
         cyc=16;
      else
         cyc=32;
      for(int i=0;i<graf[gde].size();i++){
         if(graf[gde][i]!=pret)
            dfs2(graf[gde][i],gde,cyc);
      }
      return;
   }
   if(cyc>=16)
      for(int i=0;i<E.size();i++)
         if(E[i]==sta[gde]+'0'){
            cyc=i;
         }
   cyc++;
   if(cyc==6)
      cyc=0;
   for(int i=0;i<graf[gde].size();i++)
      if(graf[gde][i]!=pret)
         dfs2(graf[gde][i],gde,cyc);
   return;
}
vector<int> Mark(int n, int M, int A, int B, vector<int> U,vector<int> V) {
   N=n;
   for(int i=0;i<M;i++){
      graf[U[i]].push_back(V[i]);
      graf[V[i]].push_back(U[i]);
   }
   BFS(0);
   /*for(int i=0;i<N;i++)
      cout<<dist[i]<<" ";
   cout<<endl;*/
   if(A==2){
      E="001011";
      vector<int> R;
      dfs2(0,0,-1);
      for(int i=0;i<M;i++){
         int koj;
         if(dist[U[i]]>dist[V[i]])
            koj=U[i];
         else
            koj=V[i];
         R.push_back(sta[koj]);
      }
      return R;
   }
   string S="012";
   vector<int> R;
   for(int i=0;i<M;i++){
      int md=min(dist[U[i]],dist[V[i]]);
      R.push_back(S[md%3]-'0');
   }
   return R;
}

#include "Catherine.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int slucaj,nalazi=0,pret=-1;
set<string> S;
void Init(int A, int B) {
   if(A==2){
      slucaj=2;
      string x="001011";
      x+=x;
      x+=x;
      for(int i=0;i+4<x.size();i++)
         S.insert(x.substr(i,5));
   }
   else
      slucaj=1;
}
bool prvipot=true;
string T;
int Move(std::vector<int> y) {
   if(slucaj==1){
      if(y[0]==0 and y[1]==0)
         return 2;
      if(y[0]==0 and y[2]==0)
         return 1;
      if(y[1]==0 and y[2]==0)
         return 0;
      if(y[0]==0)
         return 1;
      if(y[1]==0)
         return 2;
      return 0;
   }
  // cout<<"POTEZ "<<y[0]<<" "<<y[1]<<endl;
   if(0==y[0] and y[1]==0){
      nalazi=4;
      prvipot=false;
      return -1;
   }
   if(prvipot){
      if(y[0]==1 and y[1]>1){
         nalazi=4;
         pret=0;
         return 0;
      }
      if(y[1]==1 and y[0]>1){
         nalazi=4;
         pret=1;
         return 1;
      }
   }
   else{
      if(pret==1 and y[1]==0 and y[0]>1){
         nalazi=4;
         return -1;
      }
      if(pret==0 and y[0]==0 and y[1]>1){
         nalazi=4;
         return -1;
      }
      if(pret==0 and y[1]==1 and y[0]>=1){
         pret=1;
         return 1;
      }
      if(pret==1 and y[0]==1 and y[1]>=1){
         pret=0;
         return 0;
      }
   }
   if(nalazi==0){
      prvipot=false;
      if(y[0]==0 and y[1]==1){
         nalazi=4;
         pret=1;
         return 1;
      }
      if(y[1]==0 and y[0]==1){
         nalazi=4;
         pret=0;
         return 0;
      }
      nalazi++;
      if(y[0]==2){
         T+="00";
         pret=0;
         return 0;
      }
      if(y[1]==2){
         T+="11";
         pret=1;
         return 1;
      }
      T+="01";
      pret=1;
      return 1;
   }
   if(nalazi==1 or nalazi==2){
      if(y[0]==1){
         T+="0";
         nalazi++;
         pret=0;
         return 0;
      }
      T+="1";
      nalazi++;
      pret=1;
      return 1;
   }
   if(nalazi==3){
      if(y[0]==1)
         T+="0";
      else
         T+="1";
      //cout<<T<<endl;
      nalazi++;
      if(S.find(T)!=S.end()){
        // cout<<"LOSE"<<endl;
         return -1;
      }
      if(y[0]==1){
         pret=0;
         return 0;
      }
      pret=1;
      return 1;
   }
   if(y[0]==0){
      nalazi=4;
      pret=1;
      return 1;
   }
   if(y[1]==0){
      pret=0;
      return 0;
   }
   return -1;
}

Compilation message

Anthony.cpp: In function 'void BFS(int)':
Anthony.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |       for(int i=0;i<graf[tren].size();i++)
      |                   ~^~~~~~~~~~~~~~~~~~
Anthony.cpp: In function 'void dfs2(int, int, int)':
Anthony.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |       for(int i=0;i<graf[gde].size();i++){
      |                   ~^~~~~~~~~~~~~~~~~
Anthony.cpp:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |       for(int i=0;i<graf[gde].size();i++){
      |                   ~^~~~~~~~~~~~~~~~~
Anthony.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |       for(int i=0;i<E.size();i++)
      |                   ~^~~~~~~~~
Anthony.cpp:64:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |    for(int i=0;i<graf[gde].size();i++)
      |                ~^~~~~~~~~~~~~~~~~

Catherine.cpp: In function 'void Init(int, int)':
Catherine.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |       for(int i=0;i+4<x.size();i++)
      |                   ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 30 ms 15524 KB Output is correct
2 Correct 1 ms 1032 KB Output is correct
3 Correct 25 ms 15268 KB Output is correct
4 Correct 35 ms 17056 KB Output is correct
5 Correct 37 ms 17028 KB Output is correct
6 Correct 30 ms 15532 KB Output is correct
7 Correct 35 ms 15680 KB Output is correct
8 Correct 43 ms 16412 KB Output is correct
9 Correct 39 ms 16556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 15524 KB Output is correct
2 Correct 1 ms 1032 KB Output is correct
3 Correct 25 ms 15268 KB Output is correct
4 Correct 35 ms 17056 KB Output is correct
5 Correct 37 ms 17028 KB Output is correct
6 Correct 30 ms 15532 KB Output is correct
7 Correct 35 ms 15680 KB Output is correct
8 Correct 43 ms 16412 KB Output is correct
9 Correct 39 ms 16556 KB Output is correct
10 Correct 26 ms 13800 KB Output is correct
11 Correct 28 ms 13900 KB Output is correct
12 Correct 26 ms 13800 KB Output is correct
13 Correct 27 ms 13800 KB Output is correct
14 Correct 26 ms 14020 KB Output is correct
15 Correct 27 ms 14388 KB Output is correct
16 Correct 34 ms 16544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 13052 KB Output is correct
2 Correct 1 ms 1040 KB Output is correct
3 Correct 23 ms 13076 KB Output is correct
4 Correct 35 ms 14824 KB Output is correct
5 Correct 41 ms 14828 KB Output is correct
6 Correct 27 ms 13464 KB Output is correct
7 Correct 26 ms 13580 KB Output is correct
8 Correct 30 ms 14088 KB Output is correct
9 Correct 30 ms 14144 KB Output is correct
10 Correct 30 ms 13980 KB Output is correct
11 Correct 36 ms 13896 KB Output is correct
12 Correct 38 ms 13844 KB Output is correct
13 Correct 34 ms 13980 KB Output is correct
14 Correct 31 ms 14204 KB Output is correct
15 Correct 28 ms 14276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 13052 KB Output is correct
2 Correct 1 ms 1040 KB Output is correct
3 Correct 23 ms 13076 KB Output is correct
4 Correct 35 ms 14824 KB Output is correct
5 Correct 41 ms 14828 KB Output is correct
6 Correct 27 ms 13464 KB Output is correct
7 Correct 26 ms 13580 KB Output is correct
8 Correct 30 ms 14088 KB Output is correct
9 Correct 30 ms 14144 KB Output is correct
10 Correct 30 ms 13980 KB Output is correct
11 Correct 36 ms 13896 KB Output is correct
12 Correct 38 ms 13844 KB Output is correct
13 Correct 34 ms 13980 KB Output is correct
14 Correct 31 ms 14204 KB Output is correct
15 Correct 28 ms 14276 KB Output is correct
16 Correct 28 ms 12000 KB Output is correct
17 Correct 28 ms 11972 KB Output is correct
18 Correct 24 ms 12048 KB Output is correct
19 Correct 25 ms 11888 KB Output is correct
20 Correct 27 ms 12488 KB Output is correct
21 Correct 26 ms 12392 KB Output is correct
22 Correct 28 ms 14432 KB Output is correct
23 Correct 24 ms 12080 KB Output is correct
24 Correct 25 ms 11992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1292 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 1 ms 1296 KB Output is correct
4 Correct 3 ms 1288 KB Output is correct
5 Correct 2 ms 1464 KB Output is correct
6 Correct 2 ms 1416 KB Output is correct
7 Correct 2 ms 1296 KB Output is correct
8 Correct 2 ms 1416 KB Output is correct
9 Correct 2 ms 1428 KB Output is correct
10 Correct 2 ms 1424 KB Output is correct
11 Correct 2 ms 1412 KB Output is correct
12 Correct 2 ms 1288 KB Output is correct
13 Correct 2 ms 1288 KB Output is correct
14 Correct 2 ms 1288 KB Output is correct
15 Correct 2 ms 1292 KB Output is correct
16 Correct 2 ms 1288 KB Output is correct
17 Correct 2 ms 1288 KB Output is correct
18 Correct 2 ms 1288 KB Output is correct
19 Correct 2 ms 1292 KB Output is correct
20 Correct 2 ms 1332 KB Output is correct
21 Correct 2 ms 1296 KB Output is correct
22 Correct 2 ms 1288 KB Output is correct
23 Correct 2 ms 1288 KB Output is correct
24 Correct 2 ms 1284 KB Output is correct
25 Correct 2 ms 1288 KB Output is correct
26 Correct 2 ms 1344 KB Output is correct
27 Correct 2 ms 1348 KB Output is correct
28 Correct 2 ms 1300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 11340 KB Output is correct
2 Correct 40 ms 12696 KB Output is correct
3 Correct 1 ms 1036 KB Output is correct
4 Correct 22 ms 11572 KB Output is correct
5 Correct 38 ms 14204 KB Output is correct
6 Correct 41 ms 14168 KB Output is correct
7 Correct 35 ms 13276 KB Output is correct
8 Correct 27 ms 13212 KB Output is correct
9 Correct 40 ms 14092 KB Output is correct
10 Correct 31 ms 14128 KB Output is correct
11 Correct 34 ms 14188 KB Output is correct
12 Correct 30 ms 14160 KB Output is correct
13 Correct 33 ms 14088 KB Output is correct
14 Correct 32 ms 14052 KB Output is correct
15 Correct 35 ms 14300 KB Output is correct
16 Correct 33 ms 14216 KB Output is correct
17 Correct 31 ms 13840 KB Output is correct
18 Correct 30 ms 13964 KB Output is correct
19 Correct 31 ms 13876 KB Output is correct
20 Correct 36 ms 13848 KB Output is correct
21 Correct 31 ms 13940 KB Output is correct
22 Correct 34 ms 13852 KB Output is correct
23 Correct 27 ms 11792 KB Output is correct
24 Correct 31 ms 11768 KB Output is correct
25 Correct 27 ms 12152 KB Output is correct
26 Correct 26 ms 12176 KB Output is correct
27 Correct 27 ms 12908 KB Output is correct
28 Correct 27 ms 12992 KB Output is correct
29 Correct 35 ms 12924 KB Output is correct
30 Correct 36 ms 12912 KB Output is correct
31 Correct 26 ms 11904 KB Output is correct
32 Correct 27 ms 11796 KB Output is correct
33 Correct 27 ms 12244 KB Output is correct
34 Correct 26 ms 12152 KB Output is correct
35 Correct 27 ms 12812 KB Output is correct
36 Correct 31 ms 12928 KB Output is correct
37 Correct 28 ms 12844 KB Output is correct
38 Correct 37 ms 12844 KB Output is correct
39 Correct 28 ms 12780 KB Output is correct
40 Correct 27 ms 12840 KB Output is correct
41 Correct 31 ms 13432 KB Output is correct
42 Correct 30 ms 13444 KB Output is correct
43 Correct 31 ms 13376 KB Output is correct
44 Correct 30 ms 13372 KB Output is correct
45 Correct 28 ms 13464 KB Output is correct
46 Correct 32 ms 13332 KB Output is correct
47 Correct 31 ms 12644 KB Output is correct
48 Correct 28 ms 12720 KB Output is correct
49 Correct 31 ms 12580 KB Output is correct
50 Correct 27 ms 12836 KB Output is correct
51 Correct 25 ms 12052 KB Output is correct
52 Correct 27 ms 12144 KB Output is correct
53 Correct 33 ms 12052 KB Output is correct
54 Correct 26 ms 12032 KB Output is correct
55 Correct 27 ms 12024 KB Output is correct
56 Correct 32 ms 12076 KB Output is correct
57 Correct 34 ms 11964 KB Output is correct
58 Correct 33 ms 12072 KB Output is correct
59 Correct 28 ms 11964 KB Output is correct
60 Correct 26 ms 12040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 11384 KB Output is correct
2 Correct 27 ms 12684 KB Output is correct
3 Correct 1 ms 1028 KB Output is correct
4 Correct 27 ms 11604 KB Output is correct
5 Correct 33 ms 14176 KB Output is correct
6 Correct 34 ms 14200 KB Output is correct
7 Correct 30 ms 13268 KB Output is correct
8 Correct 26 ms 13320 KB Output is correct
9 Correct 37 ms 14132 KB Output is correct
10 Correct 32 ms 14124 KB Output is correct
11 Correct 46 ms 14184 KB Output is correct
12 Correct 32 ms 14140 KB Output is correct
13 Correct 32 ms 14184 KB Output is correct
14 Correct 31 ms 14060 KB Output is correct
15 Correct 31 ms 14252 KB Output is correct
16 Correct 32 ms 14264 KB Output is correct
17 Correct 28 ms 13840 KB Output is correct
18 Correct 28 ms 13788 KB Output is correct
19 Correct 28 ms 13928 KB Output is correct
20 Correct 38 ms 13848 KB Output is correct
21 Correct 36 ms 13864 KB Output is correct
22 Correct 32 ms 13888 KB Output is correct
23 Correct 25 ms 11640 KB Output is correct
24 Correct 24 ms 11716 KB Output is correct
25 Correct 30 ms 12264 KB Output is correct
26 Correct 27 ms 12280 KB Output is correct
27 Correct 27 ms 12984 KB Output is correct
28 Correct 27 ms 12908 KB Output is correct
29 Correct 30 ms 12880 KB Output is correct
30 Correct 28 ms 12848 KB Output is correct
31 Correct 25 ms 11856 KB Output is correct
32 Correct 25 ms 11844 KB Output is correct
33 Correct 31 ms 12204 KB Output is correct
34 Correct 33 ms 12124 KB Output is correct
35 Correct 27 ms 12752 KB Output is correct
36 Correct 27 ms 12820 KB Output is correct
37 Correct 34 ms 12808 KB Output is correct
38 Correct 28 ms 12796 KB Output is correct
39 Correct 27 ms 12812 KB Output is correct
40 Correct 27 ms 12932 KB Output is correct
41 Correct 30 ms 13408 KB Output is correct
42 Correct 37 ms 13448 KB Output is correct
43 Correct 30 ms 13456 KB Output is correct
44 Correct 32 ms 13392 KB Output is correct
45 Correct 32 ms 13504 KB Output is correct
46 Correct 30 ms 13392 KB Output is correct
47 Correct 27 ms 12716 KB Output is correct
48 Correct 27 ms 12576 KB Output is correct
49 Correct 27 ms 12608 KB Output is correct
50 Correct 28 ms 12744 KB Output is correct
51 Correct 27 ms 12016 KB Output is correct
52 Correct 30 ms 12020 KB Output is correct
53 Correct 29 ms 11944 KB Output is correct
54 Incorrect 26 ms 12104 KB Wrong Answer [6]
55 Halted 0 ms 0 KB -