Submission #516750

# Submission time Handle Problem Language Result Execution time Memory
516750 2022-01-22T05:41:55 Z pragmatist Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 18836 KB
#include <bits/stdc++.h>                             

#define sz(v) v.size()                                
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define x first
#define y second
#define int long long
#define nl "\n"
 
using namespace std;

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;

const int N = (int)3e5 + 7;
const int M = (int)15e6 + 7;
const ll MOD = (ll)1e9 + 7;                    
const int inf = (ll)1e9 + 7;
const ll INF = (ll)3e18 + 7;

pii dir[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};

int n, x[N], y[N], c[N], a[N];
bool used[N];

bool intersect(int i, int j) {
	int d = c[i] + c[j];
	d *= d;
	int p = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
	return p <= d; 
}

bool ok() {
	for(int i = 1; i <= n; ++i) if(!used[i]) return 0;
	return 1;
}

void solve() {                              
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> x[i] >> y[i] >> c[i];
	while(!ok()) {
		int id = 0;
		for(int i = 1; i <= n; ++i) if(!used[i] && c[i] > c[id]) id = i;
		for(int i = 1; i <= n; ++i) {
			if(!used[i] && intersect(i, id)) a[i] = id, used[i] = 1;
		}			
	}	
	for(int i = 1; i <= n; ++i) cout << a[i] << ' ';
}

signed main() {                   
	ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; ++i) {
        //cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}
/*
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 584 KB Output is correct
20 Correct 3 ms 652 KB Output is correct
21 Correct 4 ms 592 KB Output is correct
22 Correct 220 ms 624 KB Output is correct
23 Correct 191 ms 628 KB Output is correct
24 Correct 199 ms 716 KB Output is correct
25 Correct 209 ms 628 KB Output is correct
26 Correct 223 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 18756 KB Output is correct
2 Correct 118 ms 18748 KB Output is correct
3 Correct 129 ms 18400 KB Output is correct
4 Correct 153 ms 18836 KB Output is correct
5 Execution timed out 3027 ms 14536 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Execution timed out 3041 ms 6336 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3041 ms 15272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 584 KB Output is correct
20 Correct 3 ms 652 KB Output is correct
21 Correct 4 ms 592 KB Output is correct
22 Correct 220 ms 624 KB Output is correct
23 Correct 191 ms 628 KB Output is correct
24 Correct 199 ms 716 KB Output is correct
25 Correct 209 ms 628 KB Output is correct
26 Correct 223 ms 628 KB Output is correct
27 Correct 6 ms 976 KB Output is correct
28 Correct 6 ms 972 KB Output is correct
29 Correct 5 ms 984 KB Output is correct
30 Correct 909 ms 920 KB Output is correct
31 Correct 885 ms 924 KB Output is correct
32 Correct 803 ms 932 KB Output is correct
33 Correct 40 ms 7232 KB Output is correct
34 Correct 41 ms 7240 KB Output is correct
35 Correct 51 ms 7012 KB Output is correct
36 Execution timed out 3086 ms 6076 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 584 KB Output is correct
20 Correct 3 ms 652 KB Output is correct
21 Correct 4 ms 592 KB Output is correct
22 Correct 220 ms 624 KB Output is correct
23 Correct 191 ms 628 KB Output is correct
24 Correct 199 ms 716 KB Output is correct
25 Correct 209 ms 628 KB Output is correct
26 Correct 223 ms 628 KB Output is correct
27 Correct 110 ms 18756 KB Output is correct
28 Correct 118 ms 18748 KB Output is correct
29 Correct 129 ms 18400 KB Output is correct
30 Correct 153 ms 18836 KB Output is correct
31 Execution timed out 3027 ms 14536 KB Time limit exceeded
32 Halted 0 ms 0 KB -