#include <bits/stdc++.h>
#include "Alicelib.h"
using namespace std;
static bool exist1[1010];
void Alice (int N, int M, int A[], int B[]) {
vector<pair<int, int>> edges;
for (int i = 0; i < M; i++) {
if (A[i] > B[i]) {
swap(A[i], B[i]);
}
exist1[A[i]] |= (B[i] == A[i] + 1);
edges.push_back({A[i], B[i]});
}
for (int i = 0; i < N - 1; i++) {
if (!exist1[i]) {
edges.push_back({i, i + 1});
edges.push_back({i, N});
}
}
edges.push_back({N - 1, N});
InitG(N + 1, edges.size());
for (int i = 0; i < edges.size(); i++) {
MakeG(i, edges[i].first, edges[i].second);
}
}
#include <bits/stdc++.h>
#include "Boblib.h"
using namespace std;
static vector<int> adj[1010];
static int indeg[1010];
static int ind[1010];
void Bob (int N, int M, int C[], int D[]) {
//toposort!
for (int i = 0; i < M; i++) {
adj[C[i]].push_back(D[i]);
indeg[D[i]]++;
}
//toposort
vector<int> topo;
stack<int> stk;
for (int i = 0; i < N; i++) {
if (indeg[i] == 0) {
stk.push(i);
}
}
while (!stk.empty()) {
int x = stk.top();
stk.pop();
ind[x] = topo.size();
topo.push_back(x);
for (int y : adj[x]) {
if (--indeg[y] == 0) {
stk.push(y);
}
}
}
vector<pair<int, int>> ans;
int last = topo.back();
for (int x : topo) {
if (x == last) {
break;
}
bool existlast = false;
for (int y : adj[x]) {
if (y == last) {
existlast = true;
} else if (y != topo[ind[x] + 1]) {
ans.push_back(pair<int, int>(ind[x], ind[y]));
}
}
if (!existlast) {
//then x, x + 1
ans.push_back(pair<int, int>(ind[x], ind[x] + 1));
}
}
//FINAL ANSWERS!
InitMap(N - 1, ans.size());
/*
for (pair<int, int> p : ans) {
MakeMap(p.first, p.second);
}
*/
}
Compilation message
Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < edges.size(); i++) {
~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
6640 KB |
Wrong Answer [11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
6640 KB |
Wrong Answer [11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
644 ms |
31192 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |