Submission #403675

# Submission time Handle Problem Language Result Execution time Memory
403675 2021-05-13T11:08:39 Z NurstanDuisengaliev Tenis (COCI20_tenis) C++14
50 / 110
73 ms 1868 KB
// Nurstan Duisengaliev(REALBOY)
// Respa Gold_2022
// IZHO GOLD_2022
// IOI_2022 
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")*/                   
      
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define pll pair <ll, ll>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 1;
int n, a[N], b[N];
int pos[N][4], posmx[N]; 
ll ans[N], cnt[4];
void Input () {
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		pos[x][1] = i;
		posmx[x] = i;
	}
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		pos[x][2] = i;
		posmx[x] = min (posmx[x], i);
	}
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		pos[x][3] = i;
		posmx[x] = min (posmx[x], i);
	}
}
void Output () {
	cout << cnt[1] << " " << cnt[2] << " " << cnt[3] << endl;
	for (int i = 1; i <= n; i ++) {
		cout << ans[i] << " ";
	}
	exit (0);
}
void solve () {
	if (n <= 3000) {
		for (int i = 1; i < n; i ++) {
			for (int j = i + 1; j <= n; j ++) {
				int o = mod;
				int ok = min (posmx[i], posmx[j]);	
				for (int t = 1; t <= 3; t ++) {
					if (min (pos[i][t], pos[j][t]) == ok) {
						o = min (o, max (pos[i][t], pos[j][t]));
					}				
				}
				int p = -1;
				for (int t = 1; t <= 3; t ++) {
					if (min (pos[i][t], pos[j][t]) == ok && max (pos[i][t], pos[j][t]) == o) {
						 p = t;
						 break;		
					}
				}
				cnt[p] ++;
				if (pos[i][p] < pos[j][p]) ans[i] ++;
				else ans[j] ++;
			}
		}
	}
	else {
		return;	
	}
}   	
 
main () {
	boost ();
	Input ();
	solve ();
	Output ();
	return 0;
}

Compilation message

tenis.cpp:93:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   93 | main () {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 73 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 73 ms 452 KB Output is correct
5 Incorrect 17 ms 1868 KB Output isn't correct
6 Halted 0 ms 0 KB -