Submission #583012

# Submission time Handle Problem Language Result Execution time Memory
583012 2022-06-24T17:10:39 Z snasibov05 Pairs (IOI07_pairs) C++14
47 / 100
61 ms 6556 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
    int b, n, d, m; cin >> b >> n >> d >> m;
    vector<vector<int>> coord(n, vector<int>(b));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < b; ++j) cin >> coord[i][j];
    }

    if (n <= 1000){
        int ans = 0;
        for (int i = 0; i < n; ++i){
            for (int j = i+1; j < n; ++j){
                int dist = 0;
                for (int k = 0; k < b; ++k) dist += abs(coord[i][k] - coord[j][k]);
                if (dist <= d) ans++;
            }
        }

        cout << ans << "\n";
    } else if (b == 1){
        int ans = 0;
        vector<int> c(n);
        for (int i = 0; i < n; ++i) c[i] = coord[i][0];
        sort(c.begin(), c.end());
        int r = 0;
        for (int i = 0; i < n; ++i){
            while (r < n-1 && c[r+1] - c[i] <= d) r++;
            ans += r - i;
        }

        cout << ans << "\n";
    }



    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 6484 KB Output is correct
2 Correct 30 ms 6556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 6540 KB Output is correct
2 Correct 50 ms 6532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 6528 KB Output is correct
2 Correct 47 ms 6476 KB Output is correct
3 Correct 44 ms 6552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -