Submission #748861

# Submission time Handle Problem Language Result Execution time Memory
748861 2023-05-27T05:48:42 Z teerapat_ Aliens (IOI07_aliens) C++14
0 / 100
1 ms 208 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 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -