Submission #764490

# Submission time Handle Problem Language Result Execution time Memory
764490 2023-06-23T13:04:58 Z ngrace Stray Cat (JOI20_stray) C++14
85 / 100
39 ms 16080 KB
#include <bits/stdc++.h>
#include "Anthony.h"
using namespace std;
#define v vector
#define ii pair<int,int>
#define fi first
#define se second

namespace {

int FunctionExample(int i, int A) {
  return i % A;
}

}  // namespace

std::vector<int> Mark(int N, int M, int A, int B,
                      std::vector<int> U, std::vector<int> V) {
  std::vector<int> X(M);
  for (int i = 0; i < M; ++i) {
    X[i] = -1;//FunctionExample(i, A);
  }

  v<int> seq = {1,0,1,1,0,0};

  v<v<ii>> adj(N);
  for(int i=0; i<M; i++){
    adj[U[i]].push_back({V[i],i});
    adj[V[i]].push_back({U[i],i});
  }

  queue<ii> q;
  q.push({0,0});
  while(q.size()>0){
    int cur=q.front().fi;
    int dep=q.front().se;
    q.pop();

    int last=-1;
    int lastind=-1;
    for(ii it:adj[cur]){
      if(X[it.se]!=-1){
        last=X[it.se];
        lastind=it.se;
      }
    }

    if(cur==0){
      for(ii it:adj[cur]) X[it.se] = seq[0];
    }else{
      if(adj[cur].size()>2){
        for(ii it:adj[cur]){
          if(it.se!=lastind) X[it.se] = (last+1)%2;
          if(last==1) dep=1;
          else dep=0;
        }
      } else{
        for(ii it:adj[cur]){
          if(it.se!=lastind) X[it.se] = seq[dep%6];
        }
      }
    }

    for(ii it:adj[cur]){
      if(it.se!=lastind) q.push({it.fi, dep+1});
    }
  }

  //for(int i:X) cout<<i<<" ";
  //cout<<endl;

  return X;
}
#include <bits/stdc++.h>
#include "Catherine.h"
using namespace std;
#define v vector
#define ii pair<int,int>
#define fi first
#define se second

namespace {

int A, B;
int lastmark = -1;
v<int> seq = {0,0,1,1,0,1};
v<int> moves;
bool allgood = false;

}  // namespace

void Init(int A, int B) {
  ::A = A;
  ::B = B;
}

int Move(std::vector<int> y) {
  int numedge=y[0]+y[1] + (lastmark!=-1);
  
  //cout<<y[0]<<" "<<y[1]<<" "<<lastmark<<endl;

  if(lastmark==-1){
    if(numedge>2){
      allgood=true;
      lastmark = (y[0]>y[1]) ? 1 : 0;
      return lastmark;
    } else if(numedge==1){
      allgood=true;
      lastmark = (y[0]>0) ? 0 : 1;
      return lastmark;
    } 
    else{
      lastmark = (y[0]>0) ? 0 : 1;
      //cout<<"?"<<y[0]<<" "<<y[1]<<" "<<lastmark<<endl;
      moves.push_back((y[lastmark]>1) ? lastmark : (lastmark+1)%2);
      moves.push_back(lastmark);
      return lastmark;
    }
  } 

  
  if(numedge>2){
    int old=lastmark;
    y[lastmark]++;
    lastmark = (y[0]>y[1]) ? 1 : 0;
    allgood=true;
    return (old==lastmark) ? -1 : lastmark;
  }

  if(numedge==1){
    allgood=true;
    return -1;
  }

  if(allgood){
    lastmark = (y[0]==1) ? 0 : 1;
    return lastmark;
  }

  if(moves.size()==4){
    //cout<<"!"<<moves[0]<<" "<<moves[1]<<" "<<moves[2]<<" "<<moves[3]<<endl;
    bool found=false;
    int next=-1;
    for(int i=0; i<6; i++){
      if(moves[0]==seq[i] && moves[1]==seq[(i+1)%6] && moves[2]==seq[(i+2)%6] && moves[3]==seq[(i+3)%6]){
        found=true;
        next=seq[(i+4)%6];
      }
    }
    if(!found || y[next]==0){
      allgood=true;
      return -1;
    }
  }

  lastmark = (y[0]==1) ? 0 : 1;
  moves.push_back(lastmark);
  return lastmark;
}

Compilation message

Anthony.cpp:11:5: warning: 'int {anonymous}::FunctionExample(int, int)' defined but not used [-Wunused-function]
   11 | int FunctionExample(int i, int A) {
      |     ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 37 ms 14868 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 24 ms 14836 KB Output is correct
4 Correct 34 ms 16076 KB Output is correct
5 Correct 38 ms 16080 KB Output is correct
6 Correct 26 ms 15164 KB Output is correct
7 Incorrect 27 ms 15136 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 14868 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 24 ms 14836 KB Output is correct
4 Correct 34 ms 16076 KB Output is correct
5 Correct 38 ms 16080 KB Output is correct
6 Correct 26 ms 15164 KB Output is correct
7 Incorrect 27 ms 15136 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 12564 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 23 ms 12528 KB Output is correct
4 Correct 32 ms 13892 KB Output is correct
5 Correct 32 ms 13996 KB Output is correct
6 Correct 28 ms 12944 KB Output is correct
7 Incorrect 26 ms 12908 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 12564 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 23 ms 12528 KB Output is correct
4 Correct 32 ms 13892 KB Output is correct
5 Correct 32 ms 13996 KB Output is correct
6 Correct 28 ms 12944 KB Output is correct
7 Incorrect 26 ms 12908 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 2 ms 856 KB Output is correct
4 Correct 2 ms 908 KB Output is correct
5 Correct 2 ms 872 KB Output is correct
6 Correct 2 ms 900 KB Output is correct
7 Correct 2 ms 864 KB Output is correct
8 Correct 2 ms 900 KB Output is correct
9 Correct 2 ms 880 KB Output is correct
10 Correct 2 ms 900 KB Output is correct
11 Correct 2 ms 840 KB Output is correct
12 Correct 2 ms 908 KB Output is correct
13 Correct 2 ms 912 KB Output is correct
14 Correct 2 ms 900 KB Output is correct
15 Correct 2 ms 900 KB Output is correct
16 Correct 2 ms 868 KB Output is correct
17 Correct 2 ms 868 KB Output is correct
18 Correct 2 ms 908 KB Output is correct
19 Correct 2 ms 856 KB Output is correct
20 Correct 2 ms 900 KB Output is correct
21 Correct 2 ms 856 KB Output is correct
22 Correct 2 ms 860 KB Output is correct
23 Correct 2 ms 900 KB Output is correct
24 Correct 2 ms 900 KB Output is correct
25 Correct 2 ms 908 KB Output is correct
26 Correct 2 ms 908 KB Output is correct
27 Correct 2 ms 908 KB Output is correct
28 Correct 2 ms 900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 10740 KB Output is correct
2 Correct 27 ms 11660 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 22 ms 11168 KB Output is correct
5 Correct 31 ms 12360 KB Output is correct
6 Correct 30 ms 12260 KB Output is correct
7 Correct 27 ms 11532 KB Output is correct
8 Correct 27 ms 11464 KB Output is correct
9 Correct 35 ms 12276 KB Output is correct
10 Correct 34 ms 12364 KB Output is correct
11 Correct 30 ms 12264 KB Output is correct
12 Correct 31 ms 12488 KB Output is correct
13 Correct 30 ms 12300 KB Output is correct
14 Correct 31 ms 12296 KB Output is correct
15 Correct 30 ms 12268 KB Output is correct
16 Correct 31 ms 12436 KB Output is correct
17 Correct 28 ms 12084 KB Output is correct
18 Correct 26 ms 12076 KB Output is correct
19 Correct 28 ms 12080 KB Output is correct
20 Correct 33 ms 12052 KB Output is correct
21 Correct 28 ms 12068 KB Output is correct
22 Correct 27 ms 12116 KB Output is correct
23 Correct 24 ms 11296 KB Output is correct
24 Correct 25 ms 11296 KB Output is correct
25 Correct 25 ms 11444 KB Output is correct
26 Correct 26 ms 11432 KB Output is correct
27 Correct 31 ms 11852 KB Output is correct
28 Correct 27 ms 11704 KB Output is correct
29 Correct 33 ms 11700 KB Output is correct
30 Correct 27 ms 11708 KB Output is correct
31 Correct 24 ms 11280 KB Output is correct
32 Correct 24 ms 11304 KB Output is correct
33 Correct 26 ms 11376 KB Output is correct
34 Correct 25 ms 11432 KB Output is correct
35 Correct 27 ms 11716 KB Output is correct
36 Correct 27 ms 11824 KB Output is correct
37 Correct 28 ms 11720 KB Output is correct
38 Correct 30 ms 11792 KB Output is correct
39 Correct 27 ms 11632 KB Output is correct
40 Correct 27 ms 11728 KB Output is correct
41 Correct 28 ms 11968 KB Output is correct
42 Correct 28 ms 12020 KB Output is correct
43 Correct 28 ms 11860 KB Output is correct
44 Correct 28 ms 11900 KB Output is correct
45 Correct 28 ms 11928 KB Output is correct
46 Correct 28 ms 11968 KB Output is correct
47 Correct 27 ms 11536 KB Output is correct
48 Correct 27 ms 11596 KB Output is correct
49 Correct 27 ms 11376 KB Output is correct
50 Correct 33 ms 11564 KB Output is correct
51 Correct 25 ms 11460 KB Output is correct
52 Correct 25 ms 11436 KB Output is correct
53 Correct 24 ms 11376 KB Output is correct
54 Correct 25 ms 11452 KB Output is correct
55 Correct 25 ms 11448 KB Output is correct
56 Correct 26 ms 11436 KB Output is correct
57 Correct 26 ms 11296 KB Output is correct
58 Correct 26 ms 11384 KB Output is correct
59 Correct 24 ms 11444 KB Output is correct
60 Correct 24 ms 11468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 10820 KB Output is correct
2 Correct 27 ms 11568 KB Output is correct
3 Correct 1 ms 608 KB Output is correct
4 Correct 22 ms 11176 KB Output is correct
5 Correct 31 ms 12368 KB Output is correct
6 Correct 31 ms 12240 KB Output is correct
7 Correct 26 ms 11444 KB Output is correct
8 Correct 26 ms 11408 KB Output is correct
9 Correct 30 ms 12304 KB Output is correct
10 Correct 31 ms 12424 KB Output is correct
11 Correct 34 ms 12348 KB Output is correct
12 Correct 31 ms 12396 KB Output is correct
13 Correct 30 ms 12424 KB Output is correct
14 Correct 30 ms 12352 KB Output is correct
15 Correct 31 ms 12212 KB Output is correct
16 Correct 39 ms 12388 KB Output is correct
17 Correct 30 ms 12072 KB Output is correct
18 Correct 37 ms 12064 KB Output is correct
19 Correct 27 ms 12052 KB Output is correct
20 Correct 28 ms 12088 KB Output is correct
21 Correct 28 ms 11956 KB Output is correct
22 Correct 28 ms 12096 KB Output is correct
23 Correct 24 ms 11300 KB Output is correct
24 Correct 27 ms 11224 KB Output is correct
25 Correct 26 ms 11408 KB Output is correct
26 Correct 32 ms 11444 KB Output is correct
27 Correct 27 ms 11704 KB Output is correct
28 Correct 27 ms 11700 KB Output is correct
29 Correct 27 ms 11692 KB Output is correct
30 Correct 34 ms 11844 KB Output is correct
31 Correct 25 ms 11232 KB Output is correct
32 Correct 24 ms 11316 KB Output is correct
33 Correct 25 ms 11452 KB Output is correct
34 Correct 25 ms 11416 KB Output is correct
35 Correct 27 ms 11800 KB Output is correct
36 Correct 27 ms 11644 KB Output is correct
37 Correct 27 ms 11696 KB Output is correct
38 Correct 27 ms 11668 KB Output is correct
39 Correct 30 ms 11752 KB Output is correct
40 Correct 27 ms 11760 KB Output is correct
41 Correct 28 ms 11976 KB Output is correct
42 Correct 28 ms 11924 KB Output is correct
43 Correct 28 ms 11968 KB Output is correct
44 Correct 28 ms 11948 KB Output is correct
45 Correct 30 ms 11884 KB Output is correct
46 Correct 28 ms 12032 KB Output is correct
47 Correct 27 ms 11676 KB Output is correct
48 Correct 26 ms 11676 KB Output is correct
49 Correct 26 ms 11404 KB Output is correct
50 Correct 27 ms 11652 KB Output is correct
51 Correct 28 ms 11428 KB Output is correct
52 Correct 25 ms 11460 KB Output is correct
53 Correct 24 ms 11416 KB Output is correct
54 Correct 31 ms 11404 KB Output is correct
55 Correct 30 ms 11320 KB Output is correct
56 Correct 26 ms 11456 KB Output is correct
57 Correct 24 ms 11388 KB Output is correct
58 Correct 24 ms 11304 KB Output is correct
59 Correct 25 ms 11464 KB Output is correct
60 Correct 27 ms 11468 KB Output is correct