Submission #748866

# Submission time Handle Problem Language Result Execution time Memory
748866 2023-05-27T05:50:38 Z teerapat_ Pairs (IOI07_pairs) C++14
12 / 100
4000 ms 3464 KB
#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
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4035 ms 1368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4072 ms 1868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4059 ms 1848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 340 KB Output is correct
2 Incorrect 15 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4066 ms 2416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4066 ms 2512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4075 ms 2992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4083 ms 3160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4035 ms 3352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4011 ms 3464 KB Time limit exceeded
2 Halted 0 ms 0 KB -