Submission #583011

# Submission time Handle Problem Language Result Execution time Memory
583011 2022-06-24T17:10:26 Z snasibov05 Pairs (IOI07_pairs) C++14
30 / 100
69 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 6552 KB Output is correct
2 Correct 33 ms 6556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 6544 KB Output is correct
2 Correct 50 ms 6548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 6548 KB Output is correct
2 Correct 51 ms 6528 KB Output is correct
3 Correct 49 ms 6548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 5716 KB Output isn't correct
2 Halted 0 ms 0 KB -