Submission #445343

# Submission time Handle Problem Language Result Execution time Memory
445343 2021-07-17T14:35:35 Z grt Tenis (COCI20_tenis) C++17
25 / 110
41 ms 4344 KB
#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back

using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;

const int nax = 100 * 1000 + 10, INF = 1e9;
int n;
int p[3][nax];
int inv[nax][3];
bool visited[nax];
int ans[nax];
int res[3];

void match(int a, int b) {
	if(a == b) return;
	pi best = {INF, INF};
	for(int i = 0; i < 3; ++i) {
		best = min(best, {min(inv[a][i], inv[b][i]), max(inv[a][i], inv[b][i])});
	}
	for(int i = 0; i < 3; ++i) {
		if(make_pair(min(inv[a][i], inv[b][i]), max(inv[a][i], inv[b][i])) == best) {
			if(inv[a][i] < inv[b][i]) ans[a]++;
			else ans[b]++;
			res[i]++;
			return;
		}
	}
}


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int j = 0; j < 3; ++j) {
		for(int i = 1; i <= n; ++i) {
			cin >> p[j][i];
			inv[p[j][i]][j] = i;
		}
	}
	int done = 0;
	for(int i = 1; i <= n; ++i) {
		vector<int>g;
		for(int j1 = 0; j1 < 3; ++j1) {
			for(int j2 = 0; j2 < 3; ++j2) {
				if(!visited[p[j1][i]] && !visited[p[j2][i]]) {
					match(p[j1][i], p[j2][i]);
				}
			}
			if(!visited[p[j1][i]]) {
				done++;
				g.PB(j1);
			}
			visited[p[j1][i]] = true;
		}
		for(int j : g) {
			ans[p[j][i]] += n - done;
		}
	}
	
	for(int i = 0; i < 3; ++i) cout << res[i] << " ";
	cout << "\n";
	for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
}
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 332 KB Partially correct
2 Partially correct 0 ms 332 KB Partially correct
3 Partially correct 1 ms 332 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 332 KB Partially correct
2 Partially correct 0 ms 332 KB Partially correct
3 Partially correct 1 ms 332 KB Partially correct
4 Partially correct 2 ms 332 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 332 KB Partially correct
2 Partially correct 0 ms 332 KB Partially correct
3 Partially correct 1 ms 332 KB Partially correct
4 Partially correct 2 ms 332 KB Partially correct
5 Partially correct 20 ms 1596 KB Partially correct
6 Partially correct 31 ms 3396 KB Partially correct
7 Incorrect 41 ms 4344 KB Output isn't correct
8 Halted 0 ms 0 KB -