Submission #314763

# Submission time Handle Problem Language Result Execution time Memory
314763 2020-10-21T06:33:45 Z georgerapeanu Stray Cat (JOI20_stray) C++14
85 / 100
65 ms 15952 KB
//#include "Anthony.h"
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdio>

using namespace std;

const int NMAX = 20000;

int viz[NMAX + 5];
vector<pair<int,int> > graph[NMAX + 5];
int a,b;
vector<int> secv = {0,1,0,0,1,1};
vector<int> ans;

void dfs(int nod,int tata,int ind){
    queue<pair<pair<int,int>,int> > q;
    q.push({{nod,tata},ind});
    viz[nod] = true;
    while(!q.empty()){
        pair<pair<int,int>,int> tmp = q.front();
        q.pop();
        int nod = tmp.first.first;
        int tata = tmp.first.second;
        int ind = tmp.second;
        for(auto it:graph[nod]){
            if(it.first == tata){
                continue;
            }
            if(viz[it.first]){
                ans[it.second] = 2;
            }
            else{
                ans[it.second] = secv[ind];
                viz[it.first] = true;
                q.push({{it.first,nod},(graph[it.first].size() == 2 ? ((ind + 1) % 6):(1 - secv[ind]))});
            }
        }
    }
}

vector<int> Mark(int N, int M, int A, int B,vector<int> U, vector<int> V) {
    
    a = A;
    b = B;

    ans = vector<int>(M,1);

    for(int i = 0;i < M;i++){
        graph[U[i]].push_back({V[i],i});
        graph[V[i]].push_back({U[i],i});
    }

    dfs(0,-1,0);
    
    //for(int i = 0;i < M;i++)printf("%d %d %d\n",U[i],V[i],ans[i]);printf("\n");

    return ans;
}
#include "Catherine.h"
//#include <cstdio>
#include <vector>

using namespace std;

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

int lst = -1;
bool found_direction = false;

vector<vector<int> > good_secvs = 
{
    {0,1,0,0,1},
    {1,0,0,1,1},
    {0,0,1,1,0},
    {0,1,1,0,1},
    {1,1,0,1,0},
    {1,0,1,0,0}
};

vector<int> curr_secv;

int Move(vector<int> y) {
   // printf("%d %d\n",y[0],y[1]);
    
    if(found_direction){
        if(y[0] == 0){
        //    printf("deb1 %d\n",1);
            return lst = 1;
        }
        if(y[1] == 0){
     //       printf("deb1 %d\n",0);
            return lst = 0;   
        }

        if(y[1] != 1){
       //     printf("deb1 %d\n",0);
            return lst = 0;
        }

        if(y[0] != 1){
         //   printf("deb1 %d\n",1);
            return lst = 1;
        }

        //printf("deb1 %d\n",1 - lst);
        return lst = 1 - lst;
    }

    if((lst != -1) + y[0] + y[1] == 1){
        found_direction = true;
        if(lst != -1){
          //  printf("deb1.5 %d\n",-1);
            return -1;
        }
       // printf("deb2 %d\n",(y[0] == 1 ? 0:1));
        return lst = (y[0] == 1 ? 0:1);
    }

    if(y[0] + y[1] + (lst != -1) > 2){
        found_direction = true;
        if(y[0] == 0){
            if(lst == -1){
         //       printf("deb3 %d\n",1);
                return lst = 1;
            }
            else{
         //       printf("deb4 %d\n",-1);
                return -1;
            }
        }
        if(y[1] == 0){
            if(lst == -1){
         //       printf("deb5 %d\n",0);
                return lst = 0;
            }
            else{
         //       printf("deb6 %d\n",-1);
                return -1;
            }
        }
       // printf("deb7 %d\n",(((lst == 0) + y[0]) < ((lst == 1) + y[1]) ? 0:1));
        return lst = (((lst == 0) + y[0]) < ((lst == 1) + y[1]) ? 0:1);
    }

    if(lst == -1){
        if(y[0] == 2){
            lst = 0;
            curr_secv.push_back(0);
            curr_secv.push_back(0);
         //   printf("deb8 %d\n",0);
            return 0;
        }
        else if(y[0] == 1){
            lst = 0;
            curr_secv.push_back(1);
            curr_secv.push_back(0);
         //   printf("deb9 %d\n",0);
            return 0;
        }
        else{
            lst = 1;
            curr_secv.push_back(1);
            curr_secv.push_back(1);
         //   printf("deb10 %d\n",1);
            return 1;
        }
    }
    else{
        if(y[0] == 1){
            curr_secv.push_back(lst = 0);
        }
        else{
            curr_secv.push_back(lst = 1);
        }
        if(curr_secv.size() == 5){
            bool found = false;
            for(auto it:good_secvs){
                bool tmp = true;
                for(int i = 0;i < 5;i++){
                    tmp &= (it[i] == curr_secv[i]);
                }
                if(tmp){
                    found = true;
                    break;
                }
            }
            if(found == true){
                found_direction = true;
           //     printf("deb11 %d\n",-1);
                return -1;
            }
            else{
                found_direction = true;
           //     printf("deb12 %d\n",lst);
                return lst;
            }
        }
        else{
          //  printf("deb13 %d\n",lst);
            return lst;
        }
    }

    //printf("wtf\n");
    return -10;
}
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 15952 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 15952 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 48 ms 13396 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 41 ms 13236 KB Output is correct
4 Correct 65 ms 14776 KB Output is correct
5 Incorrect 62 ms 14792 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 48 ms 13396 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 41 ms 13236 KB Output is correct
4 Correct 65 ms 14776 KB Output is correct
5 Incorrect 62 ms 14792 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1744 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 2 ms 1536 KB Output is correct
4 Correct 2 ms 1536 KB Output is correct
5 Correct 2 ms 1536 KB Output is correct
6 Correct 2 ms 1536 KB Output is correct
7 Correct 2 ms 1536 KB Output is correct
8 Correct 2 ms 1536 KB Output is correct
9 Correct 2 ms 1536 KB Output is correct
10 Correct 2 ms 1536 KB Output is correct
11 Correct 2 ms 1536 KB Output is correct
12 Correct 2 ms 1536 KB Output is correct
13 Correct 2 ms 1536 KB Output is correct
14 Correct 2 ms 1536 KB Output is correct
15 Correct 2 ms 1536 KB Output is correct
16 Correct 2 ms 1536 KB Output is correct
17 Correct 2 ms 1536 KB Output is correct
18 Correct 2 ms 1536 KB Output is correct
19 Correct 2 ms 1536 KB Output is correct
20 Correct 2 ms 1536 KB Output is correct
21 Correct 2 ms 1536 KB Output is correct
22 Correct 2 ms 1536 KB Output is correct
23 Correct 2 ms 1536 KB Output is correct
24 Correct 2 ms 1792 KB Output is correct
25 Correct 2 ms 1536 KB Output is correct
26 Correct 2 ms 1536 KB Output is correct
27 Correct 2 ms 1536 KB Output is correct
28 Correct 2 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 11924 KB Output is correct
2 Correct 51 ms 12236 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 38 ms 12016 KB Output is correct
5 Correct 59 ms 13108 KB Output is correct
6 Correct 60 ms 13096 KB Output is correct
7 Correct 44 ms 12224 KB Output is correct
8 Correct 45 ms 12344 KB Output is correct
9 Correct 60 ms 13004 KB Output is correct
10 Correct 59 ms 13004 KB Output is correct
11 Correct 57 ms 13244 KB Output is correct
12 Correct 58 ms 13012 KB Output is correct
13 Correct 61 ms 13100 KB Output is correct
14 Correct 57 ms 13004 KB Output is correct
15 Correct 57 ms 13196 KB Output is correct
16 Correct 60 ms 13208 KB Output is correct
17 Correct 54 ms 12852 KB Output is correct
18 Correct 54 ms 12852 KB Output is correct
19 Correct 54 ms 12756 KB Output is correct
20 Correct 62 ms 12760 KB Output is correct
21 Correct 62 ms 12880 KB Output is correct
22 Correct 53 ms 12756 KB Output is correct
23 Correct 46 ms 11964 KB Output is correct
24 Correct 44 ms 12076 KB Output is correct
25 Correct 45 ms 11988 KB Output is correct
26 Correct 45 ms 12116 KB Output is correct
27 Correct 51 ms 12364 KB Output is correct
28 Correct 54 ms 12496 KB Output is correct
29 Correct 53 ms 12368 KB Output is correct
30 Correct 53 ms 12504 KB Output is correct
31 Correct 44 ms 12236 KB Output is correct
32 Correct 45 ms 12072 KB Output is correct
33 Correct 44 ms 12144 KB Output is correct
34 Correct 46 ms 12232 KB Output is correct
35 Correct 49 ms 12404 KB Output is correct
36 Correct 52 ms 12620 KB Output is correct
37 Correct 51 ms 12620 KB Output is correct
38 Correct 50 ms 12364 KB Output is correct
39 Correct 50 ms 12828 KB Output is correct
40 Correct 49 ms 12616 KB Output is correct
41 Correct 53 ms 12808 KB Output is correct
42 Correct 53 ms 12828 KB Output is correct
43 Correct 54 ms 12784 KB Output is correct
44 Correct 54 ms 12660 KB Output is correct
45 Correct 53 ms 12672 KB Output is correct
46 Correct 54 ms 12668 KB Output is correct
47 Correct 54 ms 12620 KB Output is correct
48 Correct 59 ms 12484 KB Output is correct
49 Correct 48 ms 12300 KB Output is correct
50 Correct 48 ms 12504 KB Output is correct
51 Correct 46 ms 12092 KB Output is correct
52 Correct 47 ms 12148 KB Output is correct
53 Correct 44 ms 11988 KB Output is correct
54 Correct 45 ms 12116 KB Output is correct
55 Correct 45 ms 12156 KB Output is correct
56 Correct 44 ms 12300 KB Output is correct
57 Correct 47 ms 12116 KB Output is correct
58 Correct 45 ms 12180 KB Output is correct
59 Correct 46 ms 12116 KB Output is correct
60 Correct 44 ms 11988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 11984 KB Output is correct
2 Correct 51 ms 12116 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 38 ms 11840 KB Output is correct
5 Correct 56 ms 13004 KB Output is correct
6 Correct 59 ms 13056 KB Output is correct
7 Correct 46 ms 12316 KB Output is correct
8 Correct 46 ms 12228 KB Output is correct
9 Correct 56 ms 13012 KB Output is correct
10 Correct 59 ms 13052 KB Output is correct
11 Correct 60 ms 13260 KB Output is correct
12 Correct 61 ms 13236 KB Output is correct
13 Correct 59 ms 13108 KB Output is correct
14 Correct 59 ms 12928 KB Output is correct
15 Correct 58 ms 13244 KB Output is correct
16 Correct 59 ms 13116 KB Output is correct
17 Correct 55 ms 12840 KB Output is correct
18 Correct 55 ms 12848 KB Output is correct
19 Correct 53 ms 12860 KB Output is correct
20 Correct 54 ms 12864 KB Output is correct
21 Correct 57 ms 12836 KB Output is correct
22 Correct 57 ms 12972 KB Output is correct
23 Correct 43 ms 12072 KB Output is correct
24 Correct 43 ms 11856 KB Output is correct
25 Correct 45 ms 12112 KB Output is correct
26 Correct 46 ms 12224 KB Output is correct
27 Correct 52 ms 12384 KB Output is correct
28 Correct 51 ms 12500 KB Output is correct
29 Correct 53 ms 12624 KB Output is correct
30 Correct 53 ms 12620 KB Output is correct
31 Correct 53 ms 11852 KB Output is correct
32 Correct 43 ms 11988 KB Output is correct
33 Correct 47 ms 12192 KB Output is correct
34 Correct 47 ms 12192 KB Output is correct
35 Correct 52 ms 12444 KB Output is correct
36 Correct 52 ms 12368 KB Output is correct
37 Correct 52 ms 12608 KB Output is correct
38 Correct 51 ms 12516 KB Output is correct
39 Correct 60 ms 12516 KB Output is correct
40 Correct 51 ms 12616 KB Output is correct
41 Correct 55 ms 12916 KB Output is correct
42 Correct 56 ms 12660 KB Output is correct
43 Correct 57 ms 12908 KB Output is correct
44 Correct 53 ms 12660 KB Output is correct
45 Correct 57 ms 12804 KB Output is correct
46 Correct 52 ms 12500 KB Output is correct
47 Correct 49 ms 12472 KB Output is correct
48 Correct 48 ms 12244 KB Output is correct
49 Correct 51 ms 12108 KB Output is correct
50 Correct 50 ms 12500 KB Output is correct
51 Correct 44 ms 12160 KB Output is correct
52 Correct 47 ms 12108 KB Output is correct
53 Correct 47 ms 12280 KB Output is correct
54 Correct 44 ms 12148 KB Output is correct
55 Correct 45 ms 12392 KB Output is correct
56 Correct 45 ms 12244 KB Output is correct
57 Correct 45 ms 11996 KB Output is correct
58 Correct 44 ms 11988 KB Output is correct
59 Correct 45 ms 12204 KB Output is correct
60 Correct 44 ms 12200 KB Output is correct