Submission #62955

# Submission time Handle Problem Language Result Execution time Memory
62955 2018-07-31T03:51:46 Z kingpig9 Airline Route Map (JOI18_airline) C++11
0 / 100
684 ms 30400 KB
#include <bits/stdc++.h>
#include "Alicelib.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

void Alice (int N, int M, int A[], int B[]) {
	vector<bool> exist1(N + 13);
	vector<pii> edges = vector<pii> ();

	for (int i = 0; i < M; i++) {
		if (A[i] > B[i]) {
			swap(A[i], B[i]);
		}
		if (B[i] == A[i] + 1) {
			exist1[A[i]] = true;
		}
		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].fi, edges[i].se);
	}
}
#include <bits/stdc++.h>
#include "Boblib.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

void Bob (int N, int M, int C[], int D[]) {
	//toposort!
	vector<vector<int>> adj(N + 15);
	vector<int> indeg(N + 19);
	vector<int> ind(N + 10);

	for (int i = 0; i < M; i++) {
		adj[C[i]].push_back(D[i]);
		indeg[D[i]]++;
	}

	//toposort
	vector<int> topo = vector<int> ();
	stack<int> stk = stack<int> ();

	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<pii> ans = vector<pii> ();
	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(pii(ind[x], ind[y]));
			}
		}

		if (!existlast) {
			//then x, x + 1
			ans.push_back(pii(ind[x], ind[x] + 1));
		}
	}

	//FINAL ANSWERS!
	InitMap(N - 1, ans.size());
	for (pii p : ans) {
		MakeMap(p.fi, p.se);
		debug("MAP %d %d\n", p.fi, p.se);
	}
}

Compilation message

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:39:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < edges.size(); i++) {
                  ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 6640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 6640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 684 ms 30400 KB Wrong Answer [11]
2 Halted 0 ms 0 KB -