Submission #763999

# Submission time Handle Problem Language Result Execution time Memory
763999 2023-06-23T05:14:23 Z boyliguanhan Stray Cat (JOI20_stray) C++17
15 / 100
39 ms 21108 KB
#include "Anthony.h"
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
vector<int> X, paint{0, 1, 0, 0, 1, 1};
vector<pair<int, int>> adj[20000];
int vis[20000];
void m1(int n = 0, int pi = -1, int depth = 0) {
    if (pi+1) X[pi] = paint[depth];
    for (auto i : adj[n]) if (i.S != pi) {
        if (adj[n].size() == 2)
            m1(i.F, i.S, (depth + 1) % 6);
        else
            m1(i.F, i.S, 1 ^ paint[depth]);
    }
}
void m2() {
    queue<int> q;
    q.push(0);
    vis[0] = 1;
    while (q.size()) {
        int n = q.front();
        q.pop();
        for (auto i : adj[n])
            if (!vis[i.F]) {
                X[i.S] = (vis[n] - 1) % 3;
                vis[i.F] = vis[n] + 1;
                q.push(i.F); 
            } else
                X[i.S] = (vis[i.F] - 1) % 3;
    }
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
    for(int i = 0; i < M; i++) {
        adj[U[i]].push_back({V[i], i});
        adj[V[i]].push_back({U[i], i});
    }
    X.resize(M);
    if (B) m1();
    else m2();
    return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
int a, b, last;
bool up;
vector<int> seen;
vector<vector<int>> poss = {{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 move_tree(vector<int> y) {
    vector<int> y2 = y;
    if (last+1) y2[last]++;
    int cnt = 0;
    for(auto i: y2)
        cnt+=i;
    if (cnt != 2)
        up = 1;
    if (up) {
        if (cnt == 1) {
            if (last==-1) for(int i = 0; i < a; i++)
                if (y[i]) return last = i;
            return -1;
        } else if (cnt == 2) {
            for(int i = 0; i < a; i++)
                if (y[i]) return last = i;
        } else {
            for(int i = 0; i < a; i++)
                if (y2[i] == 1) {
                if (!y[i]) return -1;
                return last = i;
            }
        }
    } else
        if (last+1)
            for(int i = 0; i < a; i++)
                if (y[i]) {
                    seen.push_back(i);
                    if (seen.size() < 5)
                        return last = i;
                    else {
                        up = 1;
                        for (vector<int> v : poss)
                            if (v == seen)
                                return last = i;
                        return -1;
                    }
                }
        else
            for(int i = 0; i < a; i++) 
                if (y[i]) {
                    seen.push_back(i);
                    y[i]--;
                    for(int j = 0; j < a; j++) if (y[j]) {
                        seen.push_back(j);
                        return last = j;
                    }
                }
}
int move_graph(vector<int> y) {
    if (last+1) y[last]++;
    for(int i = 0; i < 3; i++)
        if (y[i] && y[(i + 1) % 3])
            return last = i;
    for(int i = 0; i < 3; i++)
        if (y[i])
            return last = i;
}
void Init(int A, int B) {
    a = A;
    b = B;
    up = false;
    last = -1;
}
int Move(vector<int> y) {
    if (b) return move_tree(y);
    return move_graph(y);
}

Compilation message

Catherine.cpp: In function 'int move_tree(std::vector<int>)':
Catherine.cpp:32:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   32 |         if (last+1)
      |            ^
Catherine.cpp:9:22: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     vector<int> y2 = y;
      |                      ^
Catherine.cpp: In function 'int move_graph(std::vector<int>)':
Catherine.cpp:65:1: warning: control reaches end of non-void function [-Wreturn-type]
   65 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 35 ms 15964 KB Output is correct
2 Correct 1 ms 1036 KB Output is correct
3 Correct 25 ms 15056 KB Output is correct
4 Correct 38 ms 17008 KB Output is correct
5 Correct 39 ms 17096 KB Output is correct
6 Correct 28 ms 15680 KB Output is correct
7 Correct 30 ms 15724 KB Output is correct
8 Correct 32 ms 16488 KB Output is correct
9 Correct 33 ms 16324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 15964 KB Output is correct
2 Correct 1 ms 1036 KB Output is correct
3 Correct 25 ms 15056 KB Output is correct
4 Correct 38 ms 17008 KB Output is correct
5 Correct 39 ms 17096 KB Output is correct
6 Correct 28 ms 15680 KB Output is correct
7 Correct 30 ms 15724 KB Output is correct
8 Correct 32 ms 16488 KB Output is correct
9 Correct 33 ms 16324 KB Output is correct
10 Correct 27 ms 13860 KB Output is correct
11 Correct 27 ms 13876 KB Output is correct
12 Correct 26 ms 13868 KB Output is correct
13 Correct 26 ms 13828 KB Output is correct
14 Correct 33 ms 14060 KB Output is correct
15 Correct 30 ms 14468 KB Output is correct
16 Correct 32 ms 16572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 13560 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 23 ms 13016 KB Output is correct
4 Correct 35 ms 14828 KB Output is correct
5 Correct 33 ms 14856 KB Output is correct
6 Correct 28 ms 13484 KB Output is correct
7 Correct 33 ms 13728 KB Output is correct
8 Correct 32 ms 14064 KB Output is correct
9 Correct 31 ms 14212 KB Output is correct
10 Correct 30 ms 13960 KB Output is correct
11 Correct 30 ms 13888 KB Output is correct
12 Correct 31 ms 13940 KB Output is correct
13 Correct 28 ms 13924 KB Output is correct
14 Correct 31 ms 14236 KB Output is correct
15 Correct 32 ms 14316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 13560 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 23 ms 13016 KB Output is correct
4 Correct 35 ms 14828 KB Output is correct
5 Correct 33 ms 14856 KB Output is correct
6 Correct 28 ms 13484 KB Output is correct
7 Correct 33 ms 13728 KB Output is correct
8 Correct 32 ms 14064 KB Output is correct
9 Correct 31 ms 14212 KB Output is correct
10 Correct 30 ms 13960 KB Output is correct
11 Correct 30 ms 13888 KB Output is correct
12 Correct 31 ms 13940 KB Output is correct
13 Correct 28 ms 13924 KB Output is correct
14 Correct 31 ms 14236 KB Output is correct
15 Correct 32 ms 14316 KB Output is correct
16 Correct 26 ms 11976 KB Output is correct
17 Correct 28 ms 11932 KB Output is correct
18 Correct 25 ms 11948 KB Output is correct
19 Correct 26 ms 11964 KB Output is correct
20 Correct 27 ms 12604 KB Output is correct
21 Correct 27 ms 12380 KB Output is correct
22 Correct 30 ms 14216 KB Output is correct
23 Correct 26 ms 12036 KB Output is correct
24 Correct 26 ms 12092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1740 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 11760 KB Output is correct
2 Runtime error 39 ms 21108 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 20308 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -