이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cmath>
using namespace std;
int i, b, n, d, m;
long long answer, x, y , z, aux;
long double temp_aux;
long long px[100001], py[100001], pz[100001];
int main() {
answer = 0;
cin >> b >> n >> d >> m;
if(b == 1){// 1D
for(i = 1; i <= n; i++){
cin >> x;
px[i] = x;
}
for(i = 1; i <= n; i++){
for(int j = i+1; j <= n; j++){
aux = abs(px[i] - px[j]);
if(aux <= d){
answer++;
}
}
}
}
else if (b == 2){// 2D
for(i = 1; i <= n; i++){
cin >> x >> y;
px[i] = x;
py[i] = y;
}
for(i = 1; i <= n; i++){
for(int j = i+1; j <= n; j++){
temp_aux = sqrt(pow(px[i] - px[j], 2) + pow(py[i] - py[j], 2));
aux = round(temp_aux);
if (temp_aux < aux) {
aux += 1;
}
if(aux <= d){
answer++;
}
}
}
}
else if (b == 3){// 3D
for(i = 1; i <= n; i++){
cin >> x >> y >> z;
px[i] = x;
py[i] = y;
pz[i] = z;
}
for(i = 1; i <= n; i++){
for(int j = i+1; j <= n; j++){
temp_aux = sqrt(pow(px[i] - px[j], 2) + pow(py[i] - py[j], 2) + pow(pz[i] - pz[j], 2));
aux = round(temp_aux);
if (temp_aux < aux) {
aux += 1;
}
if(aux <= d){
answer++;
}
}
}
}
cout << answer << endl;
return 0;
}
# | 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... |