Submission #661439

# Submission time Handle Problem Language Result Execution time Memory
661439 2022-11-25T18:44:21 Z developerziya Pairs (IOI07_pairs) C++14
29 / 100
216 ms 524288 KB
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main (){
/*
lovhe novu b  INT
heyvanlarin sayi n INT
en boyuk mesafe d LONG LONG 
lohhenin olcusu m INT 
kordinatlar ---->A[i] B[i][i] C[i][i] INT 

*/
long long b,n,m,i,j;
long long say=0;
long long s=0,p;
long long d;
cin>>b>>n>>d>>m;
int A[n];
int B[n][4];
long long ferq [n*(n-1)/2];

p=n*(n-1);
if(b==1){
	for(i=0;i<n;i++) cin>>A[i];
    for(i=0;i<n;i++){
    	for(j=i+1;j<n;j++) {
    	
    		ferq[s]=A[i]-A[j];
		
    		s++;
		}
	}
for(i=0;i<s;i++){
	if(ferq[i]<0) ferq[i]=-1*ferq[i]	;
	 if(ferq[i]<=d) say++;
}
cout<<say;
}	
long long ferq1[n*(n-1)/2],ferq2[n*(n-1)/2],ferq3[n*(n-1)/2];
int r,t,Y[n],X[n],Z[n],q;
if(b==2){
	
	for(i=0;i<n;i++){
	cin>>r>>t;	
	Y[i]=r;
	X[i]=t;
	} 
    for(i=0;i<n;i++){
    	for(j=i+1;j<n;j++) {
    		ferq1[s]=X[i]-X[j];
		    ferq2[s]=Y[i]-Y[j];
    		s++;
		}
	}
for(i=0;i<s;i++) ferq[i]=abs(ferq1[i])+abs(ferq2[i]);

for(i=0;i<s;i++)	if(ferq[i]<=d) say++;
cout<<say;
}
/*
long long ferq1[n*(n-1)/2],ferq2[n*(n-1)/2];
int r,t,Y[n],X[n],q;
*/
if(b==3){
	for(i=0;i<n;i++){
	cin>>r>>t>>q;	
	Y[i]=r;
	X[i]=t;
	Z[i]=q;
	} 
    for(i=0;i<n;i++){
    	for(j=i+1;j<n;j++) {
    		ferq1[s]=X[i]-X[j];
		    ferq2[s]=Y[i]-Y[j];
		    ferq3[s]=Z[i]-Z[j];
    		s++;
		}
	}
for(i=0;i<s;i++) ferq[i]=abs(ferq1[i])+abs(ferq2[i])+abs(ferq3[i]);

for(i=0;i<s;i++)	if(ferq[i]<=d) say++;
cout<<say;
}


}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:16:15: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   16 | long long s=0,p;
      |               ^
pairs.cpp:20:5: warning: unused variable 'B' [-Wunused-variable]
   20 | int B[n][4];
      |     ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 206 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 202 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 15956 KB Output is correct
2 Correct 10 ms 15956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 204 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 200 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 210 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15920 KB Output is correct
2 Correct 10 ms 15844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 199 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 200 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -