Submission #748866

#TimeUsernameProblemLanguageResultExecution timeMemory
748866teerapat_Pairs (IOI07_pairs)C++14
12 / 100
4083 ms3464 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...