답안 #719160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
719160 2023-04-05T14:01:12 Z lam 길고양이 (JOI20_stray) C++14
89 / 100
54 ms 17012 KB
#include "Anthony.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
#define ff first
#define ss second
const int maxn = 2e4 + 10;
const string S = "101001";
int n,m;
bool start; int it;
vector <ii> adj[maxn];
vector <int> type;

void dfs(int x, int p, int val)
{
    int cnt = 0;
    for (ii i:adj[x])
        if (i.ff!=p) cnt++;
    if (cnt>1)
    {
        for (ii i:adj[x])
            if (i.ff!=p)
        {
            start = true;
            type[i.ss] = 1-val;
            dfs(i.ff,x,1-val);
        }
    }
    else if (cnt==1)
    {
        if (start)
        {
            start = false;
            if (val==-1||val==1) it = 0;
            else it = 2;
        }
        for (ii i:adj[x])
            if (i.ff!=p)
        {
            type[i.ss] = (S[it]-'0');
            it=(it+1)%6;
            dfs(i.ff,x,type[i.ss]);
        }
    }
}

std::vector<int> Mark(int N, int M, int A, int B,
                      std::vector<int> U, std::vector<int> V) {
    n=N; m=M;
    type.assign(m,0);
    for (int i=0; i<n; i++) adj[i].clear();
    for (int i=0; i<m; i++)
    {
        adj[U[i]].push_back({V[i],i});
        adj[V[i]].push_back({U[i],i});
    }
    if (A>2)
    {
        queue<int> q;
        vector <int> d(n,-1);
        d[0] = 0; q.push(0);
        while (!q.empty())
        {
            int u=q.front(); q.pop();
            for (ii v:adj[u])
                if (d[v.ff]==-1)
            {
                d[v.ff] = d[u]+1;
                q.push(v.ff);
            }
        }
//        for (int i=0; i<n; i++) cerr<<i<<" : "<<d[i]<<endl;
        for (int i=0; i<m; i++)
        {
            int u=U[i]; int v=V[i];
            if (d[u]>d[v]) swap(u,v);
            type[i] = (d[v]%3);
        }
        return type;
    }
    start = true;
    dfs(0,-1,1);
//    for (int i=0; i<m; i++) cerr<<type[i]<<' '; cerr<<endl;
    return type;
}
#include "Catherine.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

bool sub1;
bool _starts, _lost;
int val;
string s;

void Init(int A, int B) {
    if (A>2) sub1=1;
    else
    {
        s="";
        sub1=0;
        _starts = 1;
        _lost = 1;
    }
}

int Move(std::vector<int> y) {
//    cerr<<"? "<<_starts<<' '<<_lost<<' '<<val<<endl;
    if (sub1)
    {
        if ((y[0]>0&&y[1]>0)) return 0;
        if ((y[2]>0&&y[1]>0)) return 1;
        if ((y[0]>0&&y[2]>0)) return 2;
        if (y[0]) return 0;
        if (y[1]) return 1;
        if (y[2]) return 2;
        assert(false);
        return -1;
    }
    else
    {
        if (!_starts&&!_lost)
        {
            if (y[0]+y[1]==1)
            {
                if (y[0]) return val=0;
                else return val=1;
            }
            else if (y[0]+y[1]>1) return val=1-val;
            else return -1;
        }
        if (_starts)
        {
            _starts = false;
            if (y[0]+y[1]==2)
            {
                if (y[0]==2)
                {
                    s+="00";
                    return val=0;
                }
                else if (y[1]==2)
                {
                    s+="11";
                    return val=1;
                }
                else
                {
                    s+="01";
                    return val=1;
                }
            }
            else
            {
                _lost = false;
                if (y[0]==1) return val=0;
                else if (y[1]==1) return val=1;
                else
                {
                    assert(false);
                    return -1;
                }
            }
        }
        if (_lost)
        {
            if (y[0]+y[1]>1)
            {
                if (y[0]==0||y[1]==0)
                {
//                    cerr<<y[0]<<" & "<<y[1]<<endl;
                    _lost = false;
//                    cerr<<val<<" : "<<_starts<<' '<<_lost<<endl;
                    return -1;
                }
                _lost = false;
                return val = 1-val;
            }
            else if (y[0]+y[1]==0)
            {
                _lost = false;
                return -1;
            }
            else
            {
                if (y[0]) s+='0';
                else s+='1';
                if (s.length()==5)
                {
                    if (s=="10100"||s=="01001"||s=="10011"||s=="00110"||s=="01101"||s=="11010")
                    {
                        s="";
                        _lost = false;
                        return -1;
                    }
                    else
                    {
                        s="";
                        _lost = false;
                        if (y[0]) return val=0;
                        else return val=1;
                    }
                }
                else if (y[0]) return val=0;
                else return val=1;
            }
        }
    }
}

Compilation message

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:125:1: warning: control reaches end of non-void function [-Wreturn-type]
  125 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 15772 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 31 ms 15180 KB Output is correct
4 Correct 51 ms 17012 KB Output is correct
5 Correct 49 ms 16880 KB Output is correct
6 Correct 35 ms 15728 KB Output is correct
7 Correct 37 ms 15700 KB Output is correct
8 Correct 45 ms 16316 KB Output is correct
9 Correct 43 ms 16464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 15772 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 31 ms 15180 KB Output is correct
4 Correct 51 ms 17012 KB Output is correct
5 Correct 49 ms 16880 KB Output is correct
6 Correct 35 ms 15728 KB Output is correct
7 Correct 37 ms 15700 KB Output is correct
8 Correct 45 ms 16316 KB Output is correct
9 Correct 43 ms 16464 KB Output is correct
10 Incorrect 33 ms 13672 KB Wrong Answer [6]
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 13472 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 28 ms 13084 KB Output is correct
4 Correct 53 ms 14728 KB Output is correct
5 Correct 54 ms 14720 KB Output is correct
6 Correct 36 ms 13616 KB Output is correct
7 Correct 35 ms 13556 KB Output is correct
8 Correct 41 ms 14128 KB Output is correct
9 Correct 41 ms 14116 KB Output is correct
10 Correct 41 ms 13760 KB Output is correct
11 Correct 53 ms 13916 KB Output is correct
12 Correct 48 ms 13860 KB Output is correct
13 Correct 37 ms 13860 KB Output is correct
14 Correct 39 ms 14104 KB Output is correct
15 Correct 41 ms 14160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 13472 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 28 ms 13084 KB Output is correct
4 Correct 53 ms 14728 KB Output is correct
5 Correct 54 ms 14720 KB Output is correct
6 Correct 36 ms 13616 KB Output is correct
7 Correct 35 ms 13556 KB Output is correct
8 Correct 41 ms 14128 KB Output is correct
9 Correct 41 ms 14116 KB Output is correct
10 Correct 41 ms 13760 KB Output is correct
11 Correct 53 ms 13916 KB Output is correct
12 Correct 48 ms 13860 KB Output is correct
13 Correct 37 ms 13860 KB Output is correct
14 Correct 39 ms 14104 KB Output is correct
15 Correct 41 ms 14160 KB Output is correct
16 Incorrect 35 ms 11692 KB Wrong Answer [6]
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1288 KB Output is correct
2 Correct 1 ms 1076 KB Output is correct
3 Correct 2 ms 1288 KB Output is correct
4 Correct 2 ms 1344 KB Output is correct
5 Correct 2 ms 1296 KB Output is correct
6 Correct 2 ms 1296 KB Output is correct
7 Correct 3 ms 1332 KB Output is correct
8 Correct 2 ms 1332 KB Output is correct
9 Correct 2 ms 1296 KB Output is correct
10 Correct 4 ms 1288 KB Output is correct
11 Correct 3 ms 1268 KB Output is correct
12 Correct 3 ms 1288 KB Output is correct
13 Correct 3 ms 1320 KB Output is correct
14 Correct 2 ms 1288 KB Output is correct
15 Correct 2 ms 1296 KB Output is correct
16 Correct 2 ms 1288 KB Output is correct
17 Correct 2 ms 1292 KB Output is correct
18 Correct 2 ms 1288 KB Output is correct
19 Correct 2 ms 1296 KB Output is correct
20 Correct 2 ms 1292 KB Output is correct
21 Correct 2 ms 1288 KB Output is correct
22 Correct 2 ms 1296 KB Output is correct
23 Correct 2 ms 1296 KB Output is correct
24 Correct 2 ms 1296 KB Output is correct
25 Correct 2 ms 1296 KB Output is correct
26 Correct 2 ms 1296 KB Output is correct
27 Correct 2 ms 1296 KB Output is correct
28 Correct 2 ms 1292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 11560 KB Output is correct
2 Correct 37 ms 12508 KB Output is correct
3 Correct 1 ms 1036 KB Output is correct
4 Correct 27 ms 11344 KB Output is correct
5 Correct 41 ms 13996 KB Output is correct
6 Correct 41 ms 13968 KB Output is correct
7 Correct 41 ms 13076 KB Output is correct
8 Correct 37 ms 13168 KB Output is correct
9 Correct 43 ms 13964 KB Output is correct
10 Correct 39 ms 13964 KB Output is correct
11 Correct 44 ms 13928 KB Output is correct
12 Correct 41 ms 14024 KB Output is correct
13 Correct 40 ms 14024 KB Output is correct
14 Correct 45 ms 13932 KB Output is correct
15 Correct 40 ms 13996 KB Output is correct
16 Correct 40 ms 13964 KB Output is correct
17 Correct 43 ms 13600 KB Output is correct
18 Correct 36 ms 13728 KB Output is correct
19 Correct 38 ms 13880 KB Output is correct
20 Correct 37 ms 13640 KB Output is correct
21 Correct 37 ms 13596 KB Output is correct
22 Correct 36 ms 13704 KB Output is correct
23 Correct 35 ms 11692 KB Output is correct
24 Correct 32 ms 11588 KB Output is correct
25 Correct 31 ms 12032 KB Output is correct
26 Correct 34 ms 11944 KB Output is correct
27 Correct 37 ms 12720 KB Output is correct
28 Correct 47 ms 12728 KB Output is correct
29 Correct 39 ms 12736 KB Output is correct
30 Correct 36 ms 12736 KB Output is correct
31 Correct 36 ms 11596 KB Output is correct
32 Correct 32 ms 11504 KB Output is correct
33 Correct 43 ms 11932 KB Output is correct
34 Correct 39 ms 11844 KB Output is correct
35 Correct 35 ms 12612 KB Output is correct
36 Correct 34 ms 12588 KB Output is correct
37 Correct 34 ms 12532 KB Output is correct
38 Correct 38 ms 12584 KB Output is correct
39 Correct 41 ms 12680 KB Output is correct
40 Correct 44 ms 12904 KB Output is correct
41 Correct 36 ms 13240 KB Output is correct
42 Correct 45 ms 13148 KB Output is correct
43 Correct 47 ms 13232 KB Output is correct
44 Correct 43 ms 13256 KB Output is correct
45 Correct 37 ms 13240 KB Output is correct
46 Correct 40 ms 13316 KB Output is correct
47 Correct 35 ms 12612 KB Output is correct
48 Correct 36 ms 12508 KB Output is correct
49 Correct 34 ms 12284 KB Output is correct
50 Correct 40 ms 12576 KB Output is correct
51 Correct 35 ms 11756 KB Output is correct
52 Correct 31 ms 11720 KB Output is correct
53 Correct 31 ms 11660 KB Output is correct
54 Correct 34 ms 11728 KB Output is correct
55 Correct 33 ms 11688 KB Output is correct
56 Correct 45 ms 11816 KB Output is correct
57 Correct 33 ms 11680 KB Output is correct
58 Correct 36 ms 11724 KB Output is correct
59 Correct 33 ms 11776 KB Output is correct
60 Correct 41 ms 11884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 11564 KB Output is correct
2 Correct 36 ms 12540 KB Output is correct
3 Correct 1 ms 1032 KB Output is correct
4 Correct 32 ms 11416 KB Output is correct
5 Correct 46 ms 13964 KB Output is correct
6 Correct 44 ms 13972 KB Output is correct
7 Correct 43 ms 13068 KB Output is correct
8 Correct 36 ms 13164 KB Output is correct
9 Correct 39 ms 13936 KB Output is correct
10 Correct 39 ms 13940 KB Output is correct
11 Correct 39 ms 13988 KB Output is correct
12 Correct 41 ms 13992 KB Output is correct
13 Correct 39 ms 13828 KB Output is correct
14 Correct 39 ms 13928 KB Output is correct
15 Correct 41 ms 13964 KB Output is correct
16 Correct 49 ms 13884 KB Output is correct
17 Correct 40 ms 13608 KB Output is correct
18 Correct 37 ms 13644 KB Output is correct
19 Correct 36 ms 13728 KB Output is correct
20 Correct 38 ms 13652 KB Output is correct
21 Correct 40 ms 13720 KB Output is correct
22 Correct 47 ms 13576 KB Output is correct
23 Correct 33 ms 11456 KB Output is correct
24 Correct 32 ms 11572 KB Output is correct
25 Correct 33 ms 11960 KB Output is correct
26 Correct 32 ms 12036 KB Output is correct
27 Correct 36 ms 12860 KB Output is correct
28 Correct 38 ms 12692 KB Output is correct
29 Correct 41 ms 12744 KB Output is correct
30 Correct 38 ms 12748 KB Output is correct
31 Correct 31 ms 11544 KB Output is correct
32 Correct 32 ms 11596 KB Output is correct
33 Correct 40 ms 11988 KB Output is correct
34 Correct 37 ms 12112 KB Output is correct
35 Correct 43 ms 12548 KB Output is correct
36 Correct 41 ms 12524 KB Output is correct
37 Correct 40 ms 12576 KB Output is correct
38 Correct 38 ms 12516 KB Output is correct
39 Correct 36 ms 12640 KB Output is correct
40 Correct 37 ms 12676 KB Output is correct
41 Correct 42 ms 13264 KB Output is correct
42 Correct 39 ms 13280 KB Output is correct
43 Correct 36 ms 13308 KB Output is correct
44 Correct 43 ms 13232 KB Output is correct
45 Correct 40 ms 13232 KB Output is correct
46 Correct 40 ms 13236 KB Output is correct
47 Correct 45 ms 12428 KB Output is correct
48 Correct 34 ms 12540 KB Output is correct
49 Correct 32 ms 12356 KB Output is correct
50 Correct 35 ms 12524 KB Output is correct
51 Correct 32 ms 11636 KB Output is correct
52 Correct 35 ms 11832 KB Output is correct
53 Correct 34 ms 11828 KB Output is correct
54 Correct 34 ms 11816 KB Output is correct
55 Correct 34 ms 11760 KB Output is correct
56 Correct 32 ms 11660 KB Output is correct
57 Correct 33 ms 11692 KB Output is correct
58 Correct 30 ms 11788 KB Output is correct
59 Correct 31 ms 11800 KB Output is correct
60 Correct 39 ms 11776 KB Output is correct