제출 #409445

#제출 시각아이디문제언어결과실행 시간메모리
409445MDario게임 (IOI14_game)C++11
15 / 100
4 ms1100 KiB
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
int a[1501][1501], a1[1501];
set<int> s[1501];
void initialize(int n) {
    for(int i=0; i<n; i++){
        for(int t=i+1; t<n; t++){
            a[i][t]=-1;
            a[t][i]=-1;
            a1[i]+=t;
            a1[t]+=i;
            s[i].insert(t);
            s[t].insert(i);
        }
    }
    return ;
}

int hasEdge(int u, int v){
    if(a[u][v]!=-1)return a[u][v];
    a[u][v]=0;
    a[v][u]=0;
    s[u].erase(v);
    s[v].erase(u);
    a1[u]-=v;
    a1[v]-=u;
    while(s[u].size()==1){
        a[u][a1[u]]=1;
        a[a1[u]][u]=1;
        s[u].erase(a1[u]);
        s[a1[u]].erase(u);
        a1[a1[u]]-=u;
        u=a1[u];
    }
    while(s[v].size()==1){
        a[v][a1[v]]=1;
        a[a1[v]][v]=1;
        s[v].erase(a1[v]);
        s[a1[v]].erase(v);
        a1[a1[v]]-=v;
        v=a1[v];
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...