Submission #300228

# Submission time Handle Problem Language Result Execution time Memory
300228 2020-09-17T01:50:42 Z Elegia Carnival Tickets (IOI20_tickets) C++17
0 / 100
1 ms 256 KB
#include "tickets.h"
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <iostream>

using namespace std;

long long find_maximum(int k, vector<vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	vector<vector<int>> sgn(n, vector<int>(m));
	vector<pair<int, pair<int, int>>> profit;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < k; ++j) {
			sgn[i][j] = -1;
			profit.emplace_back(x[i][j] + x[i][j + m - k], make_pair(i, j));
		}
	}
	nth_element(profit.begin(), profit.begin() + n * k / 2, profit.end());
	for (int i = n * k / 2; i < n * k; ++i) {
		int u, v;
		tie(u, v) = profit[i].second;
		++sgn[u][v];
		++sgn[u][v + m - k];
	}
	vector<queue<int>> pos(n), neg(n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (sgn[i][j] > 0) {
				pos[i].push(j);
			} else if (sgn[i][j] < 0) {
				neg[i].push(j);
			}
		}
	}
	vector<int> level(n, -1);
	vector<vector<int>> answer(n, vector<int>(m, -1));
	for (int rep = 0; rep < k; ++rep) {
		int val = 0;
		for (int i = 0; i < n; ++i) {
			if (pos[i].empty()) {
				--val;
				answer[i][neg[i].front()] = rep;
				neg[i].pop();
				level[i] = rep;
			} else if (neg[i].empty()) {
				++val;
				answer[i][pos[i].front()] = rep;
				pos[i].pop();
				level[i] = rep;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (level[i] == rep) continue;
			if (val < 0) {
				++val;
				answer[i][pos[i].front()] = rep;
				pos[i].pop();
			} else {
				--val;
				answer[i][neg[i].front()] = rep;
				neg[i].pop();
			}
		}
	}
	allocate_tickets(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Contestant returned 298620960 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Contestant returned 860858182 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Contestant returned 6 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Contestant returned 13 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Contestant returned 13 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Contestant returned 13 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Contestant returned 298620960 but the tickets gives a total value of 1
2 Halted 0 ms 0 KB -