Submission #309653

# Submission time Handle Problem Language Result Execution time Memory
309653 2020-10-04T05:13:41 Z jainbot27 Stray Cat (JOI20_stray) C++17
20 / 100
65 ms 17444 KB
#include <iostream>
#include <vector>
#include <queue>
#include <cassert>
#include <string>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int)x.size()

#define FOR(x, y, z) for(int x = (y); x < (z); x++)
#define ROF(x, z, y) for(int x = (y-1); x >= (z); x--)
#define F0R(x, z) FOR(x, 0, z)
#define R0F(x, z) ROF(x, 0, z)
#define trav(x, y) for(auto&x:y)

using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

template<class T> inline bool ckmin(T&a, T b) {return b < a ? a = b, 1 : 0;}
template<class T> inline bool ckmax(T&a, T b) {return b > a ? a = b, 1 : 0;}

const char nl = '\n';
const int mxN = 20010;
const int MOD = 1e9 + 7;
const long long infLL = 1e18;

int n, m, a, b, d[mxN]; 
vi U, V, adj[mxN], res; vpii g[mxN];
queue<int> q;

// set<string> good{"01001", "10110", "00110", "01101", "11010", "10100"};
vector<int> list = {0, 1, 0, 0, 1, 1};
int amt[3] = {0, 1, 2};
void dfs(int u, int cur_edge, int cur = 0){
    if(cur_edge!=-1) res[cur_edge] = list[cur];
    trav(v, g[u]){
        if(cur_edge==v.s) continue;
        if(siz(g[u]) == 2 && u != 0){
            dfs(v.f, v.s, (cur+1)%6);
        }
        else{
            dfs(v.f, v.s, list[cur]^1);
        }
    }
}
vi Mark(int N, int M, int A, int B, vi Uu, vi Vv){
    U = Uu; V = Vv; n = N; m = M; a = A; b = B;
    if(a==2){
        res.resize(m);
        // 0 -> 1 -> 0 -> 0 -> 1 -> 1 -> 0 -> 1 -> 0 -> 0 -> 1 -> 1
        F0R(i, m){
            g[U[i]].pb({V[i], i});
            g[V[i]].pb({U[i], i});
        }
        dfs(0, -1, 0);
        return res;
    }
    else{
        res.resize(m);
        F0R(i, n) d[i] = MOD;
        F0R(i, m){
            adj[U[i]].pb(V[i]);
            adj[V[i]].pb(U[i]);
        }
        d[0] = 0;
        q.push(0);
        while(!q.empty()){
            int u = q.front(); q.pop();
            trav(v, adj[u]){
                if(ckmin(d[v], d[u]+1)){
                    q.push(v);
                }
            }
        }
        F0R(i, m){
            // we want to give them the value of the vertex with the higher value so that we know where to go
            if(d[U[i]]<d[V[i]])
                swap(U[i], V[i]);
            if(d[U[i]]==d[V[i]]){
                res[i] = amt[d[U[i]]%3];
            }
            else{
                res[i] = amt[d[V[i]]%3];
                // if we have distance 2 and 3
                // we will at 3 see that we have 2
            }
        }
        return res;
    }
}

#ifdef ACMX
int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N, M, A, B; cin >> N >> M >> A >> B;
    U.resize(M);
    V.resize(M);
    F0R(i, M){
        cin >> U[i] >> V[i];     
    }
    vi res = Mark(N, M, A, B, U, V);
    trav(x, res){
        cout << x << " ";
    }
    cout << nl;

    return 0;
}
#endif
#include <vector>
#include <iostream>
#include <queue>
#include <cassert>
#include <set>
#include <algorithm>
using namespace std;

#define f first
#define s second
#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int)x.size()

#define FOR(x, y, z) for(int x = (y); x < (z); x++)
#define ROF(x, z, y) for(int x = (y-1); x >= (z); x--)
#define F0R(x, z) FOR(x, 0, z)
#define R0F(x, z) ROF(x, 0, z)
#define trav(x, y) for(auto&x:y)

using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

template<class T> inline bool ckmin(T&a, T b) {return b < a ? a = b, 1 : 0;}
template<class T> inline bool ckmax(T&a, T b) {return b > a ? a = b, 1 : 0;}

const char nl = '\n';
const int mxN = 2e5 + 10;
const int MOD = 1e9 + 7;
const long long infLL = 1e18;

vector<int> list = {0, 1, 0, 0, 1, 1};
vector<int> cur;
int a, b; int choose = 0;
set<vector<int>> lists  {
    {1,1,0,0,1},
    {1,0,0,1,0},
    {0,0,1,0,1},
    {0,1,0,1,1},
    {1,0,1,1,0},
    {0,1,1,0,0},

};
int lst = -1;
void Init(int A, int B){
    a = A, b = B;
    
}
int Move(vi y){
    if(a > 2){
        if(y[0] == 0 && y[1] == 0 && y[2] == 0){
            assert(false);
        }
        else if(y[0] == 0 && y[1] == 0){
            return 2;
        }
        else if(y[1] == 0 && y[2] == 0){
            return 0;
        }
        else if(y[2] == 0 && y[0] == 0){
            return 1;
        }
        else if(y[0] == 0){
            return 1;
        }
        else if(y[1] == 0){
            return 2;
        }
        else if(y[2] == 0){
            return 0;
        }
        else{
            assert(false);
        }
    }
    else{
        int amt = y[0] + y[1] + (lst != -1);
        if(amt != 2) choose = 1;
        if(amt > 2){
            int z = y[0]; if(lst==0) z++;
            if(z>1) lst = 1;
            else lst = 0;
            if(y[lst]) return lst;
            else return -1;
        }
        if(amt == 1){
            int z = y[0]; if(lst==0) z++;
            lst = z == 1 ? 0 : 1;
            return y[lst] ? lst : -1;
        }
        if(choose == 1){
            if(y[0]) return lst = 0;
            return lst = 1;
        }
        if(lst==-1){
            F0R(i, 2) F0R(j, y[i]) cur.pb(i);
            if(y[0]) return lst = 0;
            else return lst = 1;
        }
        if(y[0]) cur.pb(0);
        if(y[1]) cur.pb(1);
        if(siz(cur)==5){
            choose = 1;
            if(lists.count(cur)){
                F0R(i, 2) if(y[i]) return lst = i;
            }
            else{
                return -1;
            }
        }
        F0R(i,2) if(y[i]) return lst = i;
    }
}
#ifdef ACMX
int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);


    return 0;
}
#endif

Compilation message

Catherine.cpp: In function 'int Move(vi)':
Catherine.cpp:117:1: warning: control reaches end of non-void function [-Wreturn-type]
  117 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 52 ms 16296 KB Output is correct
2 Correct 1 ms 2560 KB Output is correct
3 Correct 40 ms 15608 KB Output is correct
4 Correct 63 ms 17268 KB Output is correct
5 Correct 65 ms 17444 KB Output is correct
6 Correct 48 ms 16024 KB Output is correct
7 Correct 49 ms 16152 KB Output is correct
8 Correct 60 ms 16816 KB Output is correct
9 Correct 61 ms 16808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 16296 KB Output is correct
2 Correct 1 ms 2560 KB Output is correct
3 Correct 40 ms 15608 KB Output is correct
4 Correct 63 ms 17268 KB Output is correct
5 Correct 65 ms 17444 KB Output is correct
6 Correct 48 ms 16024 KB Output is correct
7 Correct 49 ms 16152 KB Output is correct
8 Correct 60 ms 16816 KB Output is correct
9 Correct 61 ms 16808 KB Output is correct
10 Correct 45 ms 14200 KB Output is correct
11 Correct 44 ms 14196 KB Output is correct
12 Correct 46 ms 14200 KB Output is correct
13 Correct 45 ms 14316 KB Output is correct
14 Correct 48 ms 14344 KB Output is correct
15 Correct 54 ms 14724 KB Output is correct
16 Correct 61 ms 16988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 14020 KB Output is correct
2 Correct 1 ms 2560 KB Output is correct
3 Correct 39 ms 13308 KB Output is correct
4 Correct 63 ms 15280 KB Output is correct
5 Correct 62 ms 15092 KB Output is correct
6 Correct 47 ms 13692 KB Output is correct
7 Correct 46 ms 13828 KB Output is correct
8 Correct 58 ms 14636 KB Output is correct
9 Correct 54 ms 14452 KB Output is correct
10 Correct 52 ms 14388 KB Output is correct
11 Correct 51 ms 14204 KB Output is correct
12 Correct 52 ms 14580 KB Output is correct
13 Correct 53 ms 14332 KB Output is correct
14 Correct 57 ms 14632 KB Output is correct
15 Correct 57 ms 14628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 14020 KB Output is correct
2 Correct 1 ms 2560 KB Output is correct
3 Correct 39 ms 13308 KB Output is correct
4 Correct 63 ms 15280 KB Output is correct
5 Correct 62 ms 15092 KB Output is correct
6 Correct 47 ms 13692 KB Output is correct
7 Correct 46 ms 13828 KB Output is correct
8 Correct 58 ms 14636 KB Output is correct
9 Correct 54 ms 14452 KB Output is correct
10 Correct 52 ms 14388 KB Output is correct
11 Correct 51 ms 14204 KB Output is correct
12 Correct 52 ms 14580 KB Output is correct
13 Correct 53 ms 14332 KB Output is correct
14 Correct 57 ms 14632 KB Output is correct
15 Correct 57 ms 14628 KB Output is correct
16 Correct 41 ms 12192 KB Output is correct
17 Correct 41 ms 12320 KB Output is correct
18 Correct 50 ms 12280 KB Output is correct
19 Correct 43 ms 12280 KB Output is correct
20 Correct 50 ms 12792 KB Output is correct
21 Correct 46 ms 12536 KB Output is correct
22 Correct 56 ms 14836 KB Output is correct
23 Correct 45 ms 12656 KB Output is correct
24 Correct 44 ms 12528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2560 KB Output is correct
2 Correct 1 ms 2560 KB Output is correct
3 Correct 2 ms 2560 KB Output is correct
4 Correct 2 ms 2560 KB Output is correct
5 Correct 3 ms 2560 KB Output is correct
6 Correct 2 ms 2560 KB Output is correct
7 Correct 2 ms 2560 KB Output is correct
8 Correct 3 ms 2560 KB Output is correct
9 Correct 2 ms 2560 KB Output is correct
10 Correct 2 ms 2560 KB Output is correct
11 Correct 2 ms 2560 KB Output is correct
12 Correct 3 ms 2560 KB Output is correct
13 Correct 2 ms 2560 KB Output is correct
14 Correct 2 ms 2560 KB Output is correct
15 Correct 2 ms 2560 KB Output is correct
16 Correct 2 ms 2560 KB Output is correct
17 Correct 2 ms 2560 KB Output is correct
18 Correct 2 ms 2560 KB Output is correct
19 Correct 2 ms 2560 KB Output is correct
20 Correct 2 ms 2560 KB Output is correct
21 Correct 2 ms 2560 KB Output is correct
22 Correct 2 ms 2560 KB Output is correct
23 Correct 2 ms 2560 KB Output is correct
24 Correct 2 ms 2560 KB Output is correct
25 Correct 2 ms 2560 KB Output is correct
26 Correct 2 ms 2560 KB Output is correct
27 Correct 2 ms 2560 KB Output is correct
28 Correct 2 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 12260 KB Output is correct
2 Correct 53 ms 13184 KB Output is correct
3 Correct 2 ms 2560 KB Output is correct
4 Correct 39 ms 11768 KB Output is correct
5 Correct 61 ms 14932 KB Output is correct
6 Correct 63 ms 14804 KB Output is correct
7 Incorrect 45 ms 13820 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 12256 KB Output is correct
2 Correct 50 ms 13044 KB Output is correct
3 Correct 1 ms 2560 KB Output is correct
4 Correct 39 ms 11952 KB Output is correct
5 Correct 60 ms 14880 KB Output is correct
6 Correct 57 ms 14840 KB Output is correct
7 Incorrect 43 ms 13940 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -