Submission #1290274

#TimeUsernameProblemLanguageResultExecution timeMemory
1290274hssaan_arif게임 (IOI14_game)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;

#define endl "\n"
#define pb push_back
// #define int long long
#define fi first
#define se second

const int N = 1505, M = 1e9 + 7, LG = 20;

int n , P[N];
vector<int> L[N];
map<pair<int,int> , bool> M;

int find(int a){
    if (P[a] == a) return a;
    return P[a] = find(P[a]);
}

void join(int a , int b){
    int pa = find(a);
    int pr = find(b);
    if (L[pa].size() < L[pr].size()){
        P[pa] = pr;
        int sz = L[pa].size();
        while(sz--){
            L[pr].pb(L[pa].back());
            L[pa].pop_back();
        }
    }else{
        P[pr] = pa;
        int sz = L[pr].size();
        while(sz--){
            L[pa].pb(L[pr].back());
            L[pr].pop_back();
        }
    }
}

void initialize(int m) {
    n = m;
}

int hasEdge(int u, int v) {
    M[{u,v}] = 1;
    for (int i : L[find(u)]){
        for (int j : L[find(v)]){
            if (!M[{i,j}]) return 0;
        }
    }
    join(u,v);
    return 1;
}

Compilation message (stderr)

game.cpp:15:27: error: conflicting declaration 'std::map<std::pair<int, int>, bool> M'
   15 | map<pair<int,int> , bool> M;
      |                           ^
game.cpp:11:21: note: previous declaration as 'const int M'
   11 | const int N = 1505, M = 1e9 + 7, LG = 20;
      |                     ^
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:47:6: error: invalid types 'const int[<brace-enclosed initializer list>]' for array subscript
   47 |     M[{u,v}] = 1;
      |      ^
game.cpp:50:19: error: invalid types 'const int[<brace-enclosed initializer list>]' for array subscript
   50 |             if (!M[{i,j}]) return 0;
      |                   ^