Submission #562967

# Submission time Handle Problem Language Result Execution time Memory
562967 2022-05-15T20:09:44 Z aryan12 Amusement Park (JOI17_amusement_park) C++17
0 / 100
27 ms 3288 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]);
    }
    queue<int> q;
    q.push(0);
    dist[0] = 0;
    while(!q.empty())
    {
        int node = q.front();
        q.pop();
        for(int to: g[node])
        {
            if(dist[to] == INF)
            {
                dist[to] = dist[node] + 1;
                q.push(to);
            }
        }
    }
    for(int i = 0; i < N; i++) 
    {
        long long x = dist[i] % 60;
        if(X & (1LL << x))
        {
            MessageBoard(i, 1);
        }
        else
        {
            MessageBoard(i, 0);
        }
    }
}
#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;
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(vis[node])
    {
        assert(par != -1);
        int value = Move(par);
        return;
    }
    vis[node] = true;
    if(val == 1 && !already_taken.count(dist[node] % 60))
    {
        long long x = dist[node] % 60;
        ans += (1LL << x);
        already_taken.insert(x);
    }
    for(int to: g[node])
    {
        // cout << "to: " << to << "\n";
        if(!vis[to])
        {
            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) 
{
    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++;
        }
    }
    assert(cnt == N - 1);
    dist[0] = 0LL;
    queue<int> q;
    q.push(0);
    while(!q.empty())
    {
        int node = q.front();
        q.pop();
        for(int to: g[node])
        {
            if(dist[to] == 1e9)
            {
                dist[to] = dist[node] + 1;
                q.push(to);
            }
        }
    }
    dfs(P, -1, (long long)(V));
    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:56:13: warning: unused variable 'value' [-Wunused-variable]
   56 |         int value = Move(par);
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1280 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3276 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1288 KB Output is correct
2 Correct 1 ms 1288 KB Output is correct
3 Correct 2 ms 1276 KB Output is correct
4 Incorrect 3 ms 1700 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3276 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3288 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -