답안 #993738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993738 2024-06-06T10:47:21 Z prvocislo 길고양이 (JOI20_stray) C++17
85 / 100
38 ms 14332 KB
// .. And I love you, it's ruining my life

#include "Anthony.h"
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;

namespace 
{
    const int d[6] = { 0, 0, 1, 0, 1, 1 };
    vector<vector<pair<int, int> > > g;
    vector<int> col;
    void dfs2(int u, int p = -1, int c = 1, int i = -1)
    {
        if (!u || g[u].size() != 2)
        {
            for (pair<int, int> v : g[u]) if (v.first != p)
            {
                col[v.second] = c ^ 1;
                dfs2(v.first, u, (c ^ 1));
            }
        }
        else
        {
            if (i == -1) i = (c ? 2 : 0);
            for (pair<int, int> v : g[u]) if (v.first != p)
            {
                col[v.second] = d[(i + 1) % 6];
                dfs2(v.first, u, d[(i + 1) % 6], (i + 1) % 6);
            }
        }
    }
}

vector<int> Mark(int n, int m, int a, int b, vector<int> u, vector<int> v) 
{
    col.assign(m, -1), g.assign(n, {});
    for (int i = 0; i < m; i++) g[u[i]].push_back({ v[i], i }), g[v[i]].push_back({ u[i], i });
    if (a == 2)
    {
        ::dfs2(0);
        return col;
    }
    else
    {
        return {};
    }
}
// All my mornings are Mondays stuck in an endless February...
// I took the miracle move-on drug, the effects were temporary

#include "Catherine.h"
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;

namespace 
{
    const int d[6] = { 0, 0, 1, 0, 1, 1 };
    int a, b, lst, go;
    vector<int> v;
    int cnt(bool rev = false)
    {
        int ans = 0;
        vector<int> v2 = v;
        if (rev) reverse(v2.begin(), v2.end());
        for (int i = 0; i < 6; i++)
        {
            bool ok = true;
            for (int j = 0; j < v2.size(); j++) if (d[(i + j) % 6] != v2[j])
            {
                ok = false;
                break;
            }
            if (ok) ans++;
        }
        return ans;
    }
}

void Init(int A, int B) 
{
    ::a = A;
    ::b = B;
    lst = -1, go = 0;
    v.clear();
}

int Move(vector<int> y) 
{
    if (a == 2)
    {
        int sum = y[0] + y[1] + (lst != -1);
        if (sum != 2)
        {
            go = 1;
            if (lst != -1) y[lst]++;
            int x = (y[0] == 1 ? 0 : 1);
            if (lst == x) return lst = x, -1;
            return lst = x;
        }
        if (go == 1)
        {
            return lst = (y[0] == 1 ? 0 : 1);
        }
        for (int i = 0; i < y.size(); i++) for (int j = 0; j < y[i]; j++) v.push_back(i);
        int fw = cnt(false), bk = cnt(true);
        if (bk == 0) // ideme sa otocit
        {
            go = 1;
            return -1;
        }
        if (fw == 0) // navzdy budem pokracovat v tomto smere
        {
            go = 1;
            int x = (y[0] == 1 ? 0 : 1);
            return lst = x;
        }
        if (lst == -1) // prvy vrchol
        {
            if (v.back() != 1) reverse(v.begin(), v.end());
            return lst = v[1];
        }
        return lst = (y[0] == 1 ? 0 : 1);
    }
}

Compilation message

Catherine.cpp: In function 'int {anonymous}::cnt(bool)':
Catherine.cpp:36:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for (int j = 0; j < v2.size(); j++) if (d[(i + j) % 6] != v2[j])
      |                             ~~^~~~~~~~~~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:72:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         for (int i = 0; i < y.size(); i++) for (int j = 0; j < y[i]; j++) v.push_back(i);
      |                         ~~^~~~~~~~~~
Catherine.cpp:92:1: warning: control reaches end of non-void function [-Wreturn-type]
   92 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 2808 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 2808 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 2796 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 2796 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1048 KB Output is correct
2 Correct 1 ms 788 KB Output is correct
3 Correct 1 ms 1048 KB Output is correct
4 Correct 1 ms 1040 KB Output is correct
5 Correct 2 ms 1048 KB Output is correct
6 Correct 2 ms 1048 KB Output is correct
7 Correct 2 ms 1144 KB Output is correct
8 Correct 0 ms 1048 KB Output is correct
9 Correct 2 ms 1048 KB Output is correct
10 Correct 2 ms 1040 KB Output is correct
11 Correct 1 ms 1060 KB Output is correct
12 Correct 1 ms 1056 KB Output is correct
13 Correct 1 ms 1040 KB Output is correct
14 Correct 2 ms 1048 KB Output is correct
15 Correct 1 ms 1048 KB Output is correct
16 Correct 0 ms 1048 KB Output is correct
17 Correct 1 ms 1048 KB Output is correct
18 Correct 0 ms 1056 KB Output is correct
19 Correct 0 ms 1056 KB Output is correct
20 Correct 2 ms 1044 KB Output is correct
21 Correct 2 ms 1048 KB Output is correct
22 Correct 1 ms 1056 KB Output is correct
23 Correct 2 ms 1048 KB Output is correct
24 Correct 2 ms 1048 KB Output is correct
25 Correct 2 ms 1048 KB Output is correct
26 Correct 1 ms 1040 KB Output is correct
27 Correct 1 ms 1056 KB Output is correct
28 Correct 2 ms 1048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 11868 KB Output is correct
2 Correct 26 ms 12884 KB Output is correct
3 Correct 0 ms 796 KB Output is correct
4 Correct 24 ms 11568 KB Output is correct
5 Correct 27 ms 14116 KB Output is correct
6 Correct 27 ms 14076 KB Output is correct
7 Correct 27 ms 13176 KB Output is correct
8 Correct 25 ms 13156 KB Output is correct
9 Correct 30 ms 14332 KB Output is correct
10 Correct 30 ms 14236 KB Output is correct
11 Correct 30 ms 14172 KB Output is correct
12 Correct 28 ms 14032 KB Output is correct
13 Correct 26 ms 14220 KB Output is correct
14 Correct 33 ms 14188 KB Output is correct
15 Correct 32 ms 14120 KB Output is correct
16 Correct 33 ms 14072 KB Output is correct
17 Correct 32 ms 13864 KB Output is correct
18 Correct 38 ms 13824 KB Output is correct
19 Correct 28 ms 13920 KB Output is correct
20 Correct 27 ms 13896 KB Output is correct
21 Correct 26 ms 13912 KB Output is correct
22 Correct 26 ms 14016 KB Output is correct
23 Correct 23 ms 11860 KB Output is correct
24 Correct 27 ms 11876 KB Output is correct
25 Correct 28 ms 12152 KB Output is correct
26 Correct 27 ms 12120 KB Output is correct
27 Correct 26 ms 12888 KB Output is correct
28 Correct 26 ms 12884 KB Output is correct
29 Correct 26 ms 12856 KB Output is correct
30 Correct 26 ms 12888 KB Output is correct
31 Correct 24 ms 11872 KB Output is correct
32 Correct 26 ms 11864 KB Output is correct
33 Correct 25 ms 12120 KB Output is correct
34 Correct 23 ms 12048 KB Output is correct
35 Correct 26 ms 12884 KB Output is correct
36 Correct 25 ms 12888 KB Output is correct
37 Correct 26 ms 12888 KB Output is correct
38 Correct 36 ms 12852 KB Output is correct
39 Correct 26 ms 12852 KB Output is correct
40 Correct 26 ms 12884 KB Output is correct
41 Correct 27 ms 13396 KB Output is correct
42 Correct 27 ms 13396 KB Output is correct
43 Correct 26 ms 13440 KB Output is correct
44 Correct 33 ms 13472 KB Output is correct
45 Correct 27 ms 13396 KB Output is correct
46 Correct 27 ms 13384 KB Output is correct
47 Correct 25 ms 12716 KB Output is correct
48 Correct 26 ms 12772 KB Output is correct
49 Correct 24 ms 12644 KB Output is correct
50 Correct 25 ms 12692 KB Output is correct
51 Correct 24 ms 11868 KB Output is correct
52 Correct 24 ms 11948 KB Output is correct
53 Correct 23 ms 11948 KB Output is correct
54 Correct 31 ms 12040 KB Output is correct
55 Correct 31 ms 12116 KB Output is correct
56 Correct 23 ms 11864 KB Output is correct
57 Correct 22 ms 11868 KB Output is correct
58 Correct 25 ms 11868 KB Output is correct
59 Correct 23 ms 11864 KB Output is correct
60 Correct 26 ms 11776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 11724 KB Output is correct
2 Correct 26 ms 12628 KB Output is correct
3 Correct 1 ms 784 KB Output is correct
4 Correct 22 ms 11556 KB Output is correct
5 Correct 31 ms 14176 KB Output is correct
6 Correct 30 ms 14020 KB Output is correct
7 Correct 30 ms 13056 KB Output is correct
8 Correct 25 ms 13156 KB Output is correct
9 Correct 30 ms 14164 KB Output is correct
10 Correct 33 ms 14104 KB Output is correct
11 Correct 30 ms 14168 KB Output is correct
12 Correct 32 ms 14176 KB Output is correct
13 Correct 28 ms 14164 KB Output is correct
14 Correct 33 ms 14224 KB Output is correct
15 Correct 28 ms 14176 KB Output is correct
16 Correct 28 ms 14164 KB Output is correct
17 Correct 28 ms 13920 KB Output is correct
18 Correct 26 ms 13784 KB Output is correct
19 Correct 27 ms 13916 KB Output is correct
20 Correct 26 ms 14056 KB Output is correct
21 Correct 37 ms 13952 KB Output is correct
22 Correct 26 ms 14012 KB Output is correct
23 Correct 23 ms 11856 KB Output is correct
24 Correct 24 ms 11720 KB Output is correct
25 Correct 28 ms 12368 KB Output is correct
26 Correct 26 ms 12328 KB Output is correct
27 Correct 34 ms 12792 KB Output is correct
28 Correct 26 ms 12880 KB Output is correct
29 Correct 28 ms 12968 KB Output is correct
30 Correct 26 ms 12888 KB Output is correct
31 Correct 23 ms 11880 KB Output is correct
32 Correct 28 ms 11876 KB Output is correct
33 Correct 24 ms 12392 KB Output is correct
34 Correct 23 ms 12372 KB Output is correct
35 Correct 25 ms 12888 KB Output is correct
36 Correct 27 ms 12884 KB Output is correct
37 Correct 26 ms 12896 KB Output is correct
38 Correct 30 ms 12784 KB Output is correct
39 Correct 25 ms 12888 KB Output is correct
40 Correct 30 ms 12820 KB Output is correct
41 Correct 30 ms 13392 KB Output is correct
42 Correct 32 ms 13412 KB Output is correct
43 Correct 26 ms 13400 KB Output is correct
44 Correct 27 ms 13508 KB Output is correct
45 Correct 27 ms 13408 KB Output is correct
46 Correct 32 ms 13248 KB Output is correct
47 Correct 24 ms 12888 KB Output is correct
48 Correct 30 ms 12860 KB Output is correct
49 Correct 25 ms 12672 KB Output is correct
50 Correct 25 ms 12884 KB Output is correct
51 Correct 22 ms 11864 KB Output is correct
52 Correct 23 ms 11784 KB Output is correct
53 Correct 23 ms 12136 KB Output is correct
54 Correct 24 ms 11864 KB Output is correct
55 Correct 24 ms 11944 KB Output is correct
56 Correct 26 ms 11896 KB Output is correct
57 Correct 22 ms 11860 KB Output is correct
58 Correct 23 ms 12268 KB Output is correct
59 Correct 24 ms 11868 KB Output is correct
60 Correct 24 ms 11856 KB Output is correct