Submission #933374

# Submission time Handle Problem Language Result Execution time Memory
933374 2024-02-25T15:11:54 Z Hanksburger Examination (JOI19_examination) C++17
2 / 100
3000 ms 338984 KB
#include <bits/stdc++.h>
using namespace std;
pair<pair<int, int>, pair<int, int> > b[100005];
pair<int, pair<int, int> > a[100005];
map<pair<int, int>, int> mp;
int ans[100005];
void upd(int x, int y)
{
    for (int i=x; i<=1e9+1; i+=i&(-i))
        for (int j=y; j<=1e9+1; j+=j&(-j))
            mp[{i, j}]++;
}
int qry(int x, int y)
{
    int res=0;
    for (int i=x; i; i-=i&(-i))
        for (int j=y; j; j-=j&(-j))
            res+=mp[{i, j}];
    return res;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, ind=1;
    cin >> n >> m;
    for (int i=1; i<=n; i++)
    {
        int x, y;
        cin >> x >> y;
        a[i]={2e9+2-x-y, {1e9+1-x, 1e9+1-y}};
    }
    for (int i=1; i<=m; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        b[i]={{2e9+2-z, i}, {1e9+1-x, 1e9+1-y}};
    }
    sort(a+1, a+n+1);
    sort(b+1, b+m+1);
    for (int i=1; i<=m; i++)
    {
        while (ind<=n && a[ind].first<=b[i].first.first)
        {
            upd(a[ind].second.first, a[ind].second.second);
            ind++;
        }
        ans[b[i].first.second]=qry(b[i].second.first, b[i].second.second);
    }
    for (int i=1; i<=m; i++)
        cout << ans[i] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2776 KB Output is correct
7 Correct 255 ms 80980 KB Output is correct
8 Correct 279 ms 80424 KB Output is correct
9 Correct 296 ms 81024 KB Output is correct
10 Correct 152 ms 41044 KB Output is correct
11 Correct 184 ms 41300 KB Output is correct
12 Correct 26 ms 2396 KB Output is correct
13 Correct 266 ms 80728 KB Output is correct
14 Correct 260 ms 80592 KB Output is correct
15 Correct 260 ms 80872 KB Output is correct
16 Correct 117 ms 28824 KB Output is correct
17 Correct 87 ms 28756 KB Output is correct
18 Correct 20 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3111 ms 338984 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3111 ms 338984 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2776 KB Output is correct
7 Correct 255 ms 80980 KB Output is correct
8 Correct 279 ms 80424 KB Output is correct
9 Correct 296 ms 81024 KB Output is correct
10 Correct 152 ms 41044 KB Output is correct
11 Correct 184 ms 41300 KB Output is correct
12 Correct 26 ms 2396 KB Output is correct
13 Correct 266 ms 80728 KB Output is correct
14 Correct 260 ms 80592 KB Output is correct
15 Correct 260 ms 80872 KB Output is correct
16 Correct 117 ms 28824 KB Output is correct
17 Correct 87 ms 28756 KB Output is correct
18 Correct 20 ms 2392 KB Output is correct
19 Execution timed out 3111 ms 338984 KB Time limit exceeded
20 Halted 0 ms 0 KB -