Submission #247518

# Submission time Handle Problem Language Result Execution time Memory
247518 2020-07-11T14:40:02 Z srvlt Seats (IOI18_seats) C++14
0 / 100
397 ms 64376 KB
#include "seats.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n = 105;
vector <int> r, c;
int rc[n][n], cc[n][n], rz[n], cz[n], res, h, w;

void add(int i, int j) {
	if (!rc[i][r[j]]) rz[i]--;
	rc[i][r[j]]++;
	rc[i][r[j] + 1]--;
	if (!rc[i][r[j] + 1]) rz[i]++;
	if (!cc[i][c[j]]) cz[i]--;
	cc[i][c[j]]++;
	cc[i][c[j] + 1]--;
	if (!cc[i][c[j] + 1]) cz[i]++;
}

void del(int i, int j) {
	rc[i][r[j]]--;
	if (!rc[i][r[j]]) rz[i]++;
	if (!rc[i][r[j] + 1]) rz[i]--;
	rc[i][r[j] + 1]++;
	cc[i][c[j]]--;
	if (!cc[i][c[j]]) cz[i]++;
	if (!cc[i][c[j] + 1]) cz[i]--;
	cc[i][c[j] + 1]++;
}

void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
	r = R, c = C, h = H, w = W;
	for (int i = 0; i < H * W; i++) {
		rz[i] = H + 1, cz[i] = W + 1;
		for (int j = 0; j <= i; j++) {
			add(i, j);
		}
		if (rz[i] == H - 1 && cz[i] == W - 1) res++;
	}
}

int swap_seats(int a, int b) {
	if (a > b) swap(a, b);
	for (int i = a + 1; i < b; i++) {
		if (rz[i] == h - 1 && cz[i] == w - 1) res--;
		del(i, a);
		add(i, b);
		if (rz[i] == h - 1 && cz[i] == w - 1) res++;
	}
	swap(r[a], r[b]);
	swap(c[a], c[b]);
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 397 ms 64376 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 10 ms 1408 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 27 ms 2036 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -