답안 #978750

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978750 2024-05-09T15:15:09 Z andrei_iorgulescu 길고양이 (JOI20_stray) C++14
20 / 100
41 ms 16860 KB
#include "Anthony.h"
#include <bits/stdc++.h>

using namespace std;

int n,m,AA,BB;
vector<int> g[20005];
vector<pair<int,int>> e;
vector<int> d;

void bfs()
{
    d.resize(n);
    for (int i = 0; i < n; i++)
        d[i] = 1e9;
    d[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty())
    {
        int nod = q.front();
        q.pop();
        for (auto vecin : g[nod])
        {
            if (d[vecin] == 1e9)
            {
                d[vecin] = 1 + d[nod];
                q.push(vecin);
            }
        }
    }
}

vector<int> ant1()
{
    bfs();
    vector<int> ans(m);
    for (int i = 0; i < e.size(); i++)
    {
        int x = e[i].first,y = e[i].second;
        ans[i] = min(d[x],d[y]) % 3;
    }
    return ans;
}

vector<int> ant2()
{
    bfs();
    vector<int> ans(m);
    for (int i = 0; i < e.size(); i++)
    {
        int x = e[i].first,y = e[i].second;
        ans[i] = min(d[x],d[y]) % 2;
    }
    return ans;
}

vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V)
{
    n = N,m = M;
    AA = A,BB = B;
    for (int i = 0; i < m; i++)
    {
        g[U[i]].push_back(V[i]);
        g[V[i]].push_back(U[i]);
        e.push_back({U[i],V[i]});
    }
    if (A >= 3)
        return ant1();
    else
        return ant2();
}

#include "Catherine.h"
#include <bits/stdc++.h>

using namespace std;

int A1,B1;

void Init(int A, int B)
{
    A1 = A;
    B1 = B;
}

int cat1(vector<int> y)
{
    if (y[0] == 0 and y[1] == 0)
        return 2;
    if (y[1] == 0 and y[2] == 0)
        return 0;
    if (y[0] == 0 and y[2] == 0)
        return 1;
    if (y[2] == 0)
        return 0;
    if (y[0] == 0)
        return 1;
    return 2;
}

int lastcul = -1;
bool gogo = false;

int cat2(vector<int> y)
{
    if (gogo == true)
    {
        lastcul = 1 - lastcul;
        return lastcul;
    }
    if (lastcul == -1)
    {
        if (y[0] + y[1] >= 3)
        {
            if (y[0] == 1)
            {
                gogo = true;
                lastcul = 0;
                return lastcul;
            }
            else
            {
                gogo = true;
                lastcul = 1;
                return lastcul;
            }
        }
        else if (y[0] + y[1] == 1)
        {
            gogo = true;
            if (y[0] == 1)
                lastcul = 0;
            else
                lastcul = 1;
            return lastcul;
        }
        else
        {
            lastcul = 0;
            return lastcul;
        }
    }
    else
    {
        if (y[0] + y[1] == 0)
        {
            gogo = true;
            return -1;
        }
        else if (y[0] + y[1] >= 2)
        {
            if (y[0] == 0 or y[1] == 0)
            {
                gogo = true;
                return -1;
            }
            else
            {
                lastcul = 1 - lastcul;
                gogo = true;
                return lastcul;
            }
        }
        else
        {
            lastcul = 1 - lastcul;
            return lastcul;
        }
    }
}

int Move(vector<int> y)
{
    if (A1 >= 3)
        return cat1(y);
    else
        return cat2(y);
}

Compilation message

Anthony.cpp: In function 'std::vector<int> ant1()':
Anthony.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < e.size(); i++)
      |                     ~~^~~~~~~~~~
Anthony.cpp: In function 'std::vector<int> ant2()':
Anthony.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i = 0; i < e.size(); i++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 15620 KB Output is correct
2 Correct 1 ms 1304 KB Output is correct
3 Correct 24 ms 15096 KB Output is correct
4 Correct 41 ms 16860 KB Output is correct
5 Correct 40 ms 16772 KB Output is correct
6 Correct 32 ms 15524 KB Output is correct
7 Correct 32 ms 15568 KB Output is correct
8 Correct 36 ms 16196 KB Output is correct
9 Correct 38 ms 16164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 15620 KB Output is correct
2 Correct 1 ms 1304 KB Output is correct
3 Correct 24 ms 15096 KB Output is correct
4 Correct 41 ms 16860 KB Output is correct
5 Correct 40 ms 16772 KB Output is correct
6 Correct 32 ms 15524 KB Output is correct
7 Correct 32 ms 15568 KB Output is correct
8 Correct 36 ms 16196 KB Output is correct
9 Correct 38 ms 16164 KB Output is correct
10 Correct 27 ms 13540 KB Output is correct
11 Correct 28 ms 13304 KB Output is correct
12 Correct 26 ms 13548 KB Output is correct
13 Correct 27 ms 13292 KB Output is correct
14 Correct 30 ms 13812 KB Output is correct
15 Correct 31 ms 14116 KB Output is correct
16 Correct 35 ms 16356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 13336 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 25 ms 12776 KB Output is correct
4 Correct 36 ms 14700 KB Output is correct
5 Correct 38 ms 14648 KB Output is correct
6 Correct 30 ms 13312 KB Output is correct
7 Correct 28 ms 13352 KB Output is correct
8 Correct 33 ms 13844 KB Output is correct
9 Correct 34 ms 14052 KB Output is correct
10 Correct 34 ms 13652 KB Output is correct
11 Correct 31 ms 13624 KB Output is correct
12 Correct 35 ms 13620 KB Output is correct
13 Correct 30 ms 13672 KB Output is correct
14 Correct 34 ms 13940 KB Output is correct
15 Correct 38 ms 13924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 13336 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 25 ms 12776 KB Output is correct
4 Correct 36 ms 14700 KB Output is correct
5 Correct 38 ms 14648 KB Output is correct
6 Correct 30 ms 13312 KB Output is correct
7 Correct 28 ms 13352 KB Output is correct
8 Correct 33 ms 13844 KB Output is correct
9 Correct 34 ms 14052 KB Output is correct
10 Correct 34 ms 13652 KB Output is correct
11 Correct 31 ms 13624 KB Output is correct
12 Correct 35 ms 13620 KB Output is correct
13 Correct 30 ms 13672 KB Output is correct
14 Correct 34 ms 13940 KB Output is correct
15 Correct 38 ms 13924 KB Output is correct
16 Correct 24 ms 11772 KB Output is correct
17 Correct 26 ms 11936 KB Output is correct
18 Correct 31 ms 11420 KB Output is correct
19 Correct 25 ms 11512 KB Output is correct
20 Correct 28 ms 12236 KB Output is correct
21 Correct 31 ms 11984 KB Output is correct
22 Correct 28 ms 14192 KB Output is correct
23 Correct 26 ms 11776 KB Output is correct
24 Correct 36 ms 11576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1560 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 2 ms 1556 KB Output is correct
4 Correct 2 ms 1572 KB Output is correct
5 Correct 2 ms 1576 KB Output is correct
6 Correct 2 ms 1564 KB Output is correct
7 Correct 2 ms 1564 KB Output is correct
8 Correct 2 ms 1560 KB Output is correct
9 Correct 2 ms 1564 KB Output is correct
10 Correct 2 ms 1560 KB Output is correct
11 Correct 2 ms 1564 KB Output is correct
12 Correct 2 ms 1572 KB Output is correct
13 Correct 2 ms 1572 KB Output is correct
14 Correct 2 ms 1564 KB Output is correct
15 Correct 2 ms 1572 KB Output is correct
16 Correct 2 ms 1576 KB Output is correct
17 Correct 2 ms 1564 KB Output is correct
18 Correct 2 ms 1568 KB Output is correct
19 Correct 2 ms 1564 KB Output is correct
20 Correct 2 ms 1564 KB Output is correct
21 Correct 2 ms 1572 KB Output is correct
22 Correct 2 ms 1564 KB Output is correct
23 Correct 2 ms 1564 KB Output is correct
24 Correct 1 ms 1564 KB Output is correct
25 Correct 2 ms 1572 KB Output is correct
26 Correct 2 ms 1564 KB Output is correct
27 Correct 2 ms 1568 KB Output is correct
28 Correct 2 ms 1572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 11524 KB Output is correct
2 Correct 28 ms 12368 KB Output is correct
3 Correct 1 ms 1300 KB Output is correct
4 Correct 23 ms 11688 KB Output is correct
5 Correct 34 ms 13296 KB Output is correct
6 Correct 32 ms 13232 KB Output is correct
7 Correct 26 ms 12580 KB Output is correct
8 Incorrect 28 ms 12608 KB Wrong Answer [6]
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 11484 KB Output is correct
2 Correct 27 ms 12164 KB Output is correct
3 Correct 1 ms 1312 KB Output is correct
4 Correct 23 ms 11708 KB Output is correct
5 Correct 32 ms 13296 KB Output is correct
6 Correct 33 ms 13268 KB Output is correct
7 Correct 27 ms 12520 KB Output is correct
8 Incorrect 24 ms 12508 KB Wrong Answer [6]
9 Halted 0 ms 0 KB -