답안 #562971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
562971 2022-05-15T20:46:36 Z aryan12 Amusement Park (JOI17_amusement_park) C++17
20 / 100
24 ms 4936 KB
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;

#define MAXN 10010
#define INF 1000000000

static vector<int> g[MAXN];
static vector<long long> dist(MAXN, INF);

void Joi(int N, int M, int A[], int B[], long long X, int T) 
{
    for(int i = 0; i < M; i++)
    {
        g[A[i]].push_back(B[i]);
        g[B[i]].push_back(A[i]);
    }
    for(int i = 0; i < N; i++) 
    {
        long long x = i % 60;
        if(X & (1LL << x))
        {
            MessageBoard(i, 1);
        }
        else
        {
            MessageBoard(i, 0);
        }
    }
    // cout << "hello" << endl;
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;

#define MAXN 10010
#define INF 1000000000

static vector<int> g[MAXN];
static vector<long long> dist(MAXN, INF);
static vector<bool> vis(MAXN, false);
static vector<int> parent(MAXN);

static long long ans = 0, subtask;
static set<int> already_taken;

static int Find(int x)
{
    if(x == parent[x]) return x;
    return parent[x] = Find(parent[x]);
}

static void Unite(int a, int b)
{
    a = Find(a), b = Find(b);
    parent[a] = b;
}

static void dfs(int node, int par, long long val)
{
    // cout << "node = " << node << ", val = " << val << "\n";
    // cout << "ans = " << ans << "\n";
    if(subtask == 3 && vis[node % 60])
    {
        assert(par != -1);
        int value = Move(par);
        return;
    }
    if(subtask == 3) vis[node % 60] = true;
    if(subtask <= 2 && vis[node])
    {
        assert(par != -1);
        int value = Move(par);
        return;
    }
    if(subtask == 2) vis[node] = true;
    if(val == 1 && !already_taken.count(node % 60))
    {
        long long x = node % 60;
        ans += (1LL << x);
        already_taken.insert(x);
    }
    for(int to: g[node])
    {
        // cout << "to: " << to << "\n";
        if(!vis[to] || (subtask == 3 && !vis[to % 60]))
        {
            int value = Move(to);
            dfs(to, node, value);
        }
    }
    if(par != -1)
    {
        int value = Move(par);
    }
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) 
{
    subtask = T;
    // cout << "hello" << endl;
    for(long long i = 0; i < N; i++)
    {
        parent[i] = i;
    }
    int cnt = 0;
    for(int i = 0; i < M; i++)
    {
        if(Find(A[i]) != Find(B[i]))
        {
            Unite(A[i], B[i]);
            g[A[i]].push_back(B[i]);
            g[B[i]].push_back(A[i]);
            cnt++;
        }
    }
    // cout << "hello" << endl;
    assert(cnt == N - 1);
    // cout << "hello x2" << endl;
    dfs(P, -1, (long long)(V));
    // cout << "hello x3" << endl;
    return ans;
}

Compilation message

Ioi.cpp: In function 'void dfs(int, int, long long int)':
Ioi.cpp:35:13: warning: unused variable 'value' [-Wunused-variable]
   35 |         int value = Move(par);
      |             ^~~~~
Ioi.cpp:42:13: warning: unused variable 'value' [-Wunused-variable]
   42 |         int value = Move(par);
      |             ^~~~~
Ioi.cpp:63:13: warning: unused variable 'value' [-Wunused-variable]
   63 |         int value = Move(par);
      |             ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2824 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3284 KB Output is correct
2 Correct 23 ms 3288 KB Output is correct
3 Correct 22 ms 3376 KB Output is correct
4 Correct 14 ms 2636 KB Output is correct
5 Correct 17 ms 3404 KB Output is correct
6 Correct 14 ms 3020 KB Output is correct
7 Correct 14 ms 2872 KB Output is correct
8 Correct 14 ms 2868 KB Output is correct
9 Correct 13 ms 2892 KB Output is correct
10 Correct 15 ms 2892 KB Output is correct
11 Correct 13 ms 2764 KB Output is correct
12 Correct 13 ms 2604 KB Output is correct
13 Correct 12 ms 2596 KB Output is correct
14 Correct 13 ms 2632 KB Output is correct
15 Correct 14 ms 2636 KB Output is correct
16 Correct 13 ms 2628 KB Output is correct
17 Correct 14 ms 2640 KB Output is correct
18 Correct 13 ms 2672 KB Output is correct
19 Correct 13 ms 2628 KB Output is correct
20 Correct 11 ms 2952 KB Output is correct
21 Correct 10 ms 2884 KB Output is correct
22 Correct 15 ms 2972 KB Output is correct
23 Correct 13 ms 2892 KB Output is correct
24 Correct 15 ms 2808 KB Output is correct
25 Correct 14 ms 2840 KB Output is correct
26 Correct 14 ms 2892 KB Output is correct
27 Correct 14 ms 2824 KB Output is correct
28 Correct 14 ms 2888 KB Output is correct
29 Correct 12 ms 2740 KB Output is correct
30 Correct 14 ms 2748 KB Output is correct
31 Correct 2 ms 1280 KB Output is correct
32 Correct 1 ms 1288 KB Output is correct
33 Correct 1 ms 1292 KB Output is correct
34 Correct 2 ms 1288 KB Output is correct
35 Correct 1 ms 1288 KB Output is correct
36 Correct 2 ms 1280 KB Output is correct
37 Correct 2 ms 1280 KB Output is correct
38 Correct 1 ms 1288 KB Output is correct
39 Correct 2 ms 1280 KB Output is correct
40 Correct 2 ms 1288 KB Output is correct
41 Correct 2 ms 1280 KB Output is correct
42 Correct 1 ms 1288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1288 KB Output is correct
2 Correct 2 ms 1276 KB Output is correct
3 Correct 2 ms 1288 KB Output is correct
4 Correct 2 ms 1564 KB Output is correct
5 Correct 2 ms 1564 KB Output is correct
6 Correct 2 ms 1560 KB Output is correct
7 Correct 3 ms 1564 KB Output is correct
8 Correct 2 ms 1564 KB Output is correct
9 Correct 9 ms 2628 KB Output is correct
10 Correct 9 ms 2636 KB Output is correct
11 Correct 10 ms 2636 KB Output is correct
12 Correct 2 ms 1280 KB Output is correct
13 Correct 0 ms 1288 KB Output is correct
14 Correct 1 ms 1280 KB Output is correct
15 Correct 1 ms 1288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 4936 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 4892 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -