답안 #298755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298755 2020-09-14T00:34:27 Z Hemimor Pairs (IOI07_pairs) C++14
30 / 100
1616 ms 4732 KB
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=76;
int tp,n,d,mx;
ll res=0;

int main(){
	scanf("%d%d%d%d",&tp,&n,&d,&mx);
	if(tp==1){
		vi a(n);
		for(int i=0;i<n;i++) scanf("%d",&a[i]);
		sort(a.begin(),a.end());
		int I=0;
		for(int i=0;i<n;i++){
			while(a[i]-a[I]>d) I++;
			res+=i-I;
		}
	}
	if(tp==2){
		assert(0);
	}
	if(tp==3){
		int a[M][M][M],b[M][M][M];
		for(int i=0;i<M;i++) for(int j=0;j<M;j++) for(int k=0;k<M;k++) a[i][j][k]=b[i][j][k]=0;
		for(int i=0;i<n;i++){
			int x,y,z;
			cin>>x>>y>>z;
			a[x][y][z]++;
			b[x][y][z]++;
		}
		for(int i=0;i<M;i++) for(int j=0;j<M;j++) for(int k=1;k<M;k++) b[i][j][k]+=b[i][j][k-1];
		for(int i=0;i<M;i++) for(int j=0;j<M;j++) for(int k=0;k<M;k++) if(a[i][j][k]){
			ll tmp=0;
			for(int I=0;I<M;I++) for(int J=0;J<M;J++){
				int t=abs(I-i)+abs(J-j);
				if(t<=d){
					res+=b[I][J][min(M-1,k+t)]-b[I][J][max(0,k-t-1)];
				}
			}
			res+=tmp*a[i][j][k];
		}
		res/=2;
	}
	printf("%lld\n",res);
}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |  scanf("%d%d%d%d",&tp,&n,&d,&mx);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:46:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |   for(int i=0;i<n;i++) scanf("%d",&a[i]);
      |                        ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 768 KB Output is correct
2 Correct 19 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 768 KB Output is correct
2 Correct 27 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 768 KB Output is correct
2 Correct 27 ms 768 KB Output is correct
3 Correct 26 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 3968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 4540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 907 ms 4732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1616 ms 4728 KB Output isn't correct
2 Halted 0 ms 0 KB -