Submission #453266

# Submission time Handle Problem Language Result Execution time Memory
453266 2021-08-04T10:18:31 Z prvocislo Pairs (IOI07_pairs) C++17
40 / 100
464 ms 10964 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int b, n, d, m;
    cin >> b >> n >> d >> m;
    vector<int> x(n), y(n), z(n);
    if (b == 3)
    {
        const int maxn = 80;
        vector<vector<vector<int> > > pf(maxn, vector<vector<int> >(maxn * 2, vector<int>(maxn * 2, 0)));
        for (int i = 0, x1, y1; i < n; i++)
        {
            cin >> x1 >> y1 >> z[i];
            x[i] = x1 + y1, y[i] = maxn + x1 - y1;
            pf[z[i]][x[i]][y[i]]++;
        }
        for (int i = 0; i < pf.size(); i++) for (int j = 1; j < pf[i].size(); j++) for (int k = 1; k < pf[i][j].size(); k++)
            pf[i][j][k] += pf[i][j - 1][k] + pf[i][j][k - 1] - pf[i][j - 1][k - 1];
        ll ans = 0;
        for (int i = 0; i < n; i++) for (int zi = 0; zi < maxn; zi++)
        {
            int di = d - abs(zi - z[i]);
            if (di < 0) continue;
            int x1 = max(1, x[i] - di), y1 = max(1, y[i] - di), x2 = min(maxn * 2 - 1, x[i] + di), y2 = min(maxn * 2 - 1, y[i] + di);
            ans += pf[zi][x2][y2] - pf[zi][x1 - 1][y2] - pf[zi][x2][y1 - 1] + pf[zi][x1 - 1][y1 - 1];
            //cout << pf[zi][x2][y2] - pf[zi][x1 - 1][y2] - pf[zi][x2][y1 - 1] + pf[zi][x1 - 1][y1 - 1] << "\n";
        }
        ans -= n;
        cout << ans / 2 << "\n";
    }
    return 0;
}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:25:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int i = 0; i < pf.size(); i++) for (int j = 1; j < pf[i].size(); j++) for (int k = 1; k < pf[i][j].size(); k++)
      |                         ~~^~~~~~~~~~~
pairs.cpp:25:63: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int i = 0; i < pf.size(); i++) for (int j = 1; j < pf[i].size(); j++) for (int k = 1; k < pf[i][j].size(); k++)
      |                                                             ~~^~~~~~~~~~~~~~
pairs.cpp:25:102: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int i = 0; i < pf.size(); i++) for (int j = 1; j < pf[i].size(); j++) for (int k = 1; k < pf[i][j].size(); k++)
      |                                                                                                    ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 8952 KB Output is correct
2 Correct 13 ms 8908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 10120 KB Output is correct
2 Correct 62 ms 10108 KB Output is correct
3 Correct 81 ms 10732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 10060 KB Output is correct
2 Correct 441 ms 10948 KB Output is correct
3 Correct 134 ms 10956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 263 ms 10120 KB Output is correct
2 Correct 464 ms 10964 KB Output is correct
3 Correct 127 ms 10948 KB Output is correct