답안 #1065516

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065516 2024-08-19T08:52:16 Z Jarif_Rahman Amusement Park (JOI17_amusement_park) C++17
0 / 100
7 ms 2780 KB
#include "Joi.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

namespace {
    const int N = 10000;
    const int k = 60;
    int n, m;
    vector<int> graph[N];
    vector<int> msg;

    int ls = 0;
    void dfs(int nd){
        if(msg[nd] != -1) return;
        msg[nd] = ls;
        ls++, ls%k;
        for(int x: graph[nd]) dfs(x);
    }
}

void Joi(int _n, int _m, int A[], int B[], ll X, int T){
    n = _n, m = _m;
    for(int i = 0; i < m; i++){
        graph[A[i]].push_back(B[i]);
        graph[B[i]].push_back(A[i]);
    }

    vector<int> bin;
    for(int i = 0; i < k; i++){
        bin.push_back(X%2);
        X/=2;
    }

    msg.assign(n, -1);
    dfs(0);
    for(int i = 0; i < n; i++) MessageBoard(i, bin[msg[i]]);
}
#include "Ioi.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

namespace {
    const int N = 10000;
    const int k = 60;
    int n, m;
    vector<int> graph[N];
    vector<int> tree[N];
    vector<int> msg;

    int ls = 0;
    void dfs(int nd){
        if(msg[nd] != -1) return;
        msg[nd] = ls;
        ls++, ls%k;
        for(int x: graph[nd]) dfs(x);
    }
}

ll Ioi(int _n, int _m, int A[], int B[], int p, int v, int T){
    n = _n, m = _m;
    for(int i = 0; i < m; i++){
        graph[A[i]].push_back(B[i]);
        graph[B[i]].push_back(A[i]);
    }

    msg.assign(n, -1);
    dfs(0);

    vector<bool> done(k, 0);
    int left = k;
    vector<bool> bl(n, 0);

    done[msg[p]] = 1;
    left--;
    bl[p] = 1;

    vector<pair<int, int>> nxt;
    for(int x: graph[p]) if(!bl[x]){
        bl[x] = 1;
        nxt.push_back({x, p});
    }

    while(left){
        int nd = -1, ss = -1;
        for(int i = int(nxt.size())-1; i >= 0; i--) if(!done[msg[nxt[i].first]]){
            tie(nd, ss) = nxt[i];
            nxt.erase(nxt.begin()+i);
            break;
        }
        if(nd == -1){
            assert(!nxt.empty());
            tie(nd, ss) = nxt.back();
            nxt.pop_back();
        }

        if(!done[msg[nd]]) left--;
        done[msg[nd]] = 1;
        bl[nd] = 1;

        tree[ss].push_back(nd);

        for(int x: graph[nd]) if(!bl[x]){
            bl[x] = 1;
            nxt.push_back({x, nd});
        }
    }

    vector<int> bin(k);
    bin[msg[p]] = v;

    function<void(int)> dfs2 = [&](int nd){
        for(int x: tree[nd]){
            bin[msg[x]] = Move(x);
            dfs2(x);
            Move(nd);
        }
    };

    dfs2(p);

    ll X = 0;
    for(int i = 0; i < k; i++) if(bin[i]) X+=(1LL<<i);
    return X;
}

Compilation message

Joi.cpp: In function 'void {anonymous}::dfs(int)':
Joi.cpp:21:17: warning: right operand of comma operator has no effect [-Wunused-value]
   21 |         ls++, ls%k;
      |               ~~^~

Ioi.cpp: In function 'void {anonymous}::dfs(int)':
Ioi.cpp:22:17: warning: right operand of comma operator has no effect [-Wunused-value]
   22 |         ls++, ls%k;
      |               ~~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1564 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2764 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1556 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 2760 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2780 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -