Submission #62973

# Submission time Handle Problem Language Result Execution time Memory
62973 2018-07-31T04:14:05 Z kingpig9 Airline Route Map (JOI18_airline) C++11
0 / 100
637 ms 31340 KB
#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();
		topo.push_back(x);
 
		for (int y : adj[x]) {
			if (--indeg[y] == 0) {
				stk.push(y);
			}
		}
	}

	for (int i = 0; i < topo.size(); i++) {
		ind[topo[i]] = i;
	}
 
	vector<pair<int, int>> ans;
	int last = topo.back();
	for (int i = 0; i + 1 < topo.size(); i++) {
		int x = topo[i];
 
		bool existlast = false;
		for (int y : adj[x]) {
			if (y == last) {
				existlast = true;
			} else if (y != topo[i + 1]) {
				ans.push_back(pair<int, int>(i, ind[y]));
			}
		}
 
		if (!existlast) {
			//then x, x + 1
			ans.push_back(pair<int, int>(i, i + 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++) {
                  ~~^~~~~~~~~~~~~~

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