| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 298759 | Hemimor | Pairs (IOI07_pairs) | C++14 | 3406 ms | 4472 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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};
class Segment_Tree{
	private:
	int n;
	vi date;
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vi(2*n-1);
	}
	void Update(int k,int x){
		k+=n-1;
		date[k]+=x;
		while(k>0){
			k=(k-1)/2;
			date[k]=date[k*2+1]+date[k*2+2];
		}
	}
	int Query(int a,int b){
		a+=n-1;b+=n-1;
		int m=0;
		while(a<b){
			if(a%2==0) m+=date[a++];
			if(b%2==0) m+=date[--b];
			a/=2;b/=2;
		}
		return m;
	}
	int Open(int k){return date[k+n-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){
		vp a(n);
		for(int i=0;i<n;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			a[i]=make_pair(x-y,x+y);
		}
		sort(a.begin(),a.end());
		Segment_Tree st(200000);
		int I=0;
		for(auto p:a){
			int x=p.first,y=p.second;
			while(x-a[I].first>d) st.Update(a[I++].second,-1);
			res+=st.Query(y-d,y+d+1);
			st.Update(y,1);
		}
	}
	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;
			scanf("%d%d%d",&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=-1;
			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){
					tmp+=b[I][J][min(M-1,k+d-t)]-b[I][J][max(0,k-d+t-1)];
				}
			}
			res+=tmp*a[i][j][k];
		}
		res/=2;
	}
	printf("%lld\n",res);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
