이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
#include "game.h"
const int MAX = 1505;
int N;
vector<vi> adj(MAX, vi(MAX, 0));
// 0 if not done
// 1 if missing
// 2 if filled
void initialize(int n) {
N = n;
}
int hasEdge(int u, int v) {
/* cout<<"adj: "<<endl;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cout<<adj[i][j]<<" ";
}
cout<<endl;
}*/
// check if connecting u to v makes any "bad triangle"
// bad triangle u, v, w if (u, v) = 2, (u, w) = 2, and (v, w) isn't 1
// or if (v, w) = 2 and (u, w) isn't 1
bool can = true;
for (int i = 0; i < N; i++) {
if (adj[u][i] == 2 && adj[v][i] != 1)
can = false;
if (adj[v][i] == 2 && adj[u][i] != 1)
can = false;
}
if (can) {
adj[u][v] = 2;
adj[v][u] = 2;
return 1;
}
else {
adj[u][v] = 1;
adj[v][u] = 1;
return 0;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |