Submission #1025446

# Submission time Handle Problem Language Result Execution time Memory
1025446 2024-07-17T03:38:24 Z HappyCapybara Game (IOI14_game) C++17
0 / 100
1 ms 600 KB
#include "game.h"
#include<bits/stdc++.h>
using namespace std;

int N;
vector<int> w;
list<int> l;
vector<vector<int>> am;

void initialize(int n){
    N = n;
    w.resize(N, N-1);
    for (int i=0; i<N; i++) l.push_back(i);
    am.resize(N, vector<int>(N, 1));
    for (int i=0; i<N; i++) am[i][i] = 0;
}

_List_iterator<int> pp(_List_iterator<int> it){
    it++;
    if (it == l.end()) it = l.begin();
    return it;
}

_List_iterator<int> mm(_List_iterator<int> it){
    if (it == l.begin()) it = l.end();
    it--;
    return it;
}

int hasEdge(int u, int v){
    if (w[u] == 2 || w[v] == 2){
        am[u][v] = 2;
        am[v][u] = 2;
        return 1;
    }
    auto up = find(l.begin(), l.end(), u);
    auto vp = find(l.begin(), l.end(), v);
    up = pp(up);
    vp = pp(vp);
    if (*up == v || *vp == u){
        if (*vp == u){
            swap(u, v);
            swap(up, vp);
        }
        up = mm(up);
        vp = mm(vp);
        auto it = pp(vp);
        if (am[*up][*it]){
            auto it2 = pp(it);
            for (int i=0; i<N-3; i++){
                if (am[*vp][*it] && am[*vp][*it2]){
                    l.erase(vp);
                    if (it2 == l.begin()) l.push_back(v);
                    else l.insert(it2, v);
                    am[u][v] = 0;
                    am[v][u] = 0;
                    return 0;
                }
                it = pp(it);
                it2 = pp(it2);
            }
        }
        am[u][v] = 2;
        am[v][u] = 2;
        return 1;
    }
    am[u][v] = 0;
    am[v][u] = 0;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -