답안 #565976

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
565976 2022-05-21T15:57:09 Z Spade1 항공 노선도 (JOI18_airline) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "Alicelib.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

int cnt = 0;

void Alice(int N, int M, int A[], int B[]) {
    int binarycount = 0;
    for (int i = 0; i < N; ++i) {
        binarycount += __builtin_popcount(i);
    }
    InitG(N+12, N+M+binarycount+10);
    for (int i = 0; i < M; ++i) {
        MakeG(cnt++, A[i], B[i]);
    }
    for (int i = 0; i < N; ++i) {
        MakeG(cnt++, N, i);
    }
    MakeG(cnt++, N+1, N);
    for (int i = N+2; i < N+11; ++i) {
        MakeG(cnt++, i, i+1);
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (i & (1<<j)) MakeG(cnt++, i, N+2+j);
        }
    }
}
#include<bits/stdc++.h>
#include "Boblib.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

vector<int> adj[1050];
int unmap[1050];
int bit[11];
bool part[1050];
int deg[1050];
set<int> sbit;

void findbit(int i) {
    if (i == 10) return;
    for (auto j : adj[bit[i]]) {
        if (!sbit.count(j) && !part[j]) {
            bit[i+1] = j;
            sbit.insert(j);
            break;
        }
    }
    findbit(i+1);
}

void Bob(int V, int U, int C[], int D[]) {
    int binarycount = 0;
    int N = V-12
    for (int i = 0; i < N; ++i) {
        binarycount += __builtin_popcount(i);
    }
    int M = U-V+2-binarycount;
    InitMap(N, M);
    for (int i = 0; i < V; ++i) {
        adj[C[i]].pb(D[i]);
        adj[D[i]].pb(C[i]);
        deg[C[i]]++, deg[D[i]]++;
    }
    int key, ckey;
    for (int i = 0; i < V; ++i) {
        if (deg[i] == 1 && deg[adj[i][0]] == N+1) {
            key = adj[i][0];
            ckey = i;
        }
    }

    for (auto i : adj[key]) {
        if (i != ckey) part[i] = 1;
    }

    vector<int> edge;
    for (int i = 0; i < V; ++i) {
        if (i == key || i == ckey) continue;
        if (!part[i]) {
            int cnt = 0;
            for (auto j : adj[i]) {
                if (part[j]) continue;
                cnt++;
            }
            if (cnt == 1) edge.pb(i);
        }
    }

    if (deg[edge[0]] > deg[edge[1]]) bit[1] = edge[0];
    else bit[1] = edge[1];

    sbit.insert(bit[1]);
    findbit(1);

    for (int i = 0; i < V; ++i) {
        if (i == key || i == ckey) continue;
        if (sbit.count(i)) continue;
        for (auto k : adj[i]) {
            for (int j = 0; j < 10; ++j) {
                if (k == bit[j+1]) unmap[i] += (1<<j);
            }
        }
    }

    for (int i = 0; i < U; ++i) {
        if (C[i] == key || D[i] == key) continue;
        if (C[i] == ckey || D[i] == ckey) continue;
        if (sbit.count(C[i]) || sbit.count(D[i])) continue;
        MakeMap(unmap[D[i]], unmap[C[i]]);
    }
}

Compilation message

Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:35:5: error: expected ',' or ';' before 'for'
   35 |     for (int i = 0; i < N; ++i) {
      |     ^~~
Bob.cpp:35:21: error: 'i' was not declared in this scope
   35 |     for (int i = 0; i < N; ++i) {
      |                     ^