Submission #1040419

# Submission time Handle Problem Language Result Execution time Memory
1040419 2024-08-01T03:48:30 Z tamir1 Pairs (IOI07_pairs) C++17
47 / 100
72 ms 8792 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
ordered_set s;
ll b,n,m,d,i,j,x[100010],y[100010],z[100010];
ll ans;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> b >> n >> d >> m;
	if(b==1) for(i=1;i<=n;i++) cin >> x[i],s.insert(x[i]);
	if(b==2) for(i=1;i<=n;i++) cin >> x[i] >> y[i];
	if(b==3) for(i=1;i<=n;i++) cin >> x[i] >> y[i] >> z[i];
	if(n<=1000){
		for(i=1;i<n;i++){
			for(j=i+1;j<=n;j++){
				if(abs(x[i]-x[j])+abs(y[i]-y[j])+abs(z[i]-z[j])<=d) ans++;
			}
		}
		cout << ans;
		return 0;
	}
	if(b==1){
		for(i=1;i<=n;i++){
			ans=ans+s.order_of_key(x[i]+d+1)-s.order_of_key(x[i]-d)-1;
		}
		ans/=2;
		cout << ans;
		return 0;
	}
	cout << 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 8696 KB Output is correct
2 Correct 43 ms 8784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 8788 KB Output is correct
2 Correct 37 ms 8688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 8784 KB Output is correct
2 Correct 53 ms 8692 KB Output is correct
3 Correct 51 ms 8792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 2516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -