Submission #252387

# Submission time Handle Problem Language Result Execution time Memory
252387 2020-07-25T12:21:03 Z shayan_p Circle selection (APIO18_circle_selection) C++14
7 / 100
3000 ms 8416 KB
// And you curse yourself for things you never done

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn = 3e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

pair<pii, int> p[maxn];
int arr[maxn];

pii operator - (pii a, pii b){
    return {a.F - b.F, a.S - b.S};
}
pii operator + (pii a, pii b){
    return {a.F + b.F, a.S + b.S};
}
ll operator ^ (pii a, pii b){
    return 1ll * a.F * b.F + 1ll * a.S * b.S;
}

bool ok(int i, int j){
    return 1ll * (p[j].S + p[i].S) * (p[j].S + p[i].S) >= ((p[i].F - p[j].F) ^ (p[i].F - p[j].F));
}

int ans[maxn];

bool COM(int l1, int r1, int l2, int r2){
    return max(l1, l2) <= min(r1, r2);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();

    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
	cin >> p[i].F.F >> p[i].F.S >> p[i].S;
	arr[i] = i;
    }
    sort(arr, arr + n, [](int i, int j){ return (p[i].S == p[j].S ? i > j : p[i].S < p[j].S); } );
    vector<int> vec;
    for(int i = n-1; i >= 0; i--){
	int num = 0;
	for(int x : vec)
	    num+= COM(p[ arr[i] ].F.F - p[ arr[i] ].S, p[ arr[i] ].F.F + p[ arr[i] ].S, p[x].F.F - p[x].S, p[x].F.F + p[x].S) && COM(p[ arr[i] ].F.S - p[ arr[i] ].S, p[ arr[i] ].F.S + p[ arr[i] ].S, p[x].F.S - p[x].S, p[x].F.S + p[x].S);
	assert(num <= 10);
	for(int x : vec){
	    if(ok(arr[i], x)){
		ans[arr[i]] = x + 1;
		break;
	    }
	}
	if(ans[ arr[i] ] == 0){
	    ans[ arr[i] ] = arr[i] + 1;
	    vec.PB(arr[i]);
	}
    }
    for(int i = 0; i < n; i++){
	cout << ans[i] << " ";
    }
    return cout << endl, 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 4 ms 488 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 76 ms 512 KB Output is correct
23 Correct 76 ms 512 KB Output is correct
24 Correct 72 ms 512 KB Output is correct
25 Correct 70 ms 568 KB Output is correct
26 Correct 67 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 182 ms 8416 KB Output is correct
2 Correct 190 ms 8312 KB Output is correct
3 Correct 191 ms 8116 KB Output is correct
4 Correct 185 ms 8312 KB Output is correct
5 Execution timed out 3069 ms 6392 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 360 KB Output is correct
2 Execution timed out 3054 ms 2744 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3081 ms 5824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 4 ms 488 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 76 ms 512 KB Output is correct
23 Correct 76 ms 512 KB Output is correct
24 Correct 72 ms 512 KB Output is correct
25 Correct 70 ms 568 KB Output is correct
26 Correct 67 ms 512 KB Output is correct
27 Correct 7 ms 640 KB Output is correct
28 Correct 7 ms 596 KB Output is correct
29 Correct 7 ms 640 KB Output is correct
30 Correct 283 ms 888 KB Output is correct
31 Correct 298 ms 800 KB Output is correct
32 Correct 311 ms 772 KB Output is correct
33 Correct 66 ms 2980 KB Output is correct
34 Correct 71 ms 2940 KB Output is correct
35 Correct 67 ms 2936 KB Output is correct
36 Execution timed out 3064 ms 2596 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 4 ms 488 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 76 ms 512 KB Output is correct
23 Correct 76 ms 512 KB Output is correct
24 Correct 72 ms 512 KB Output is correct
25 Correct 70 ms 568 KB Output is correct
26 Correct 67 ms 512 KB Output is correct
27 Correct 182 ms 8416 KB Output is correct
28 Correct 190 ms 8312 KB Output is correct
29 Correct 191 ms 8116 KB Output is correct
30 Correct 185 ms 8312 KB Output is correct
31 Execution timed out 3069 ms 6392 KB Time limit exceeded
32 Halted 0 ms 0 KB -