답안 #803858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
803858 2023-08-03T06:18:56 Z moel_solution(#10136) Vera and Modern Art (CCO17_art) C++17
25 / 25
3664 ms 94684 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int lst[200010][60];
ll ans[200010];
vector<int>idlst[200010];
vector<pi>smlst[200010];
ll sum[200010];
int idx(const vector<ll>&v,ll y)
{
    auto it=upper_bound(all(v),y)-v.begin();
    if(it!=0&&v[it-1]!=y)
        it=0;
    return it;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,q;
    cin>>n>>q;
    vector<ll>cvx,cvy;
    vector<pair<pl,ll> >nv(n);
    for(auto&t:nv)
        cin>>t.fi.fi>>t.fi.se>>t.se,
        cvx.eb(t.fi.fi),
        cvy.eb(t.fi.se);
    sort(all(cvx));
    cvx.erase(unique(all(cvx)),cvx.end());
    sort(all(cvy));
    cvy.erase(unique(all(cvy)),cvy.end());
    for(auto&t:nv)
        t.fi.fi=idx(cvx,t.fi.fi),
        t.fi.se=idx(cvy,t.fi.se);
    for(auto&t:nv)
        smlst[t.fi.fi].eb(t.fi.se,t.se);
    vector<pl>qv(q);
    for(pl&t:qv)
        cin>>t.fi>>t.se;
    for(int i=0;i<q;i++)
    {
        for(int j=0;j<60;j++)
        {
            ll d=1ll<<j;
            if(qv[i].fi<d)
                break;
            ll cur=d+(qv[i].fi&(d-1));
            int id=idx(cvx,cur);
            if(id!=0)
                idlst[id].eb(i);
        }
        for(int j=0;j<60;j++)
        {
            ll d=1ll<<j;
            if(qv[i].se<d)
                break;
            ll cur=d+(qv[i].se&(d-1));
            lst[i][j]=idx(cvy,cur);
        }
    }
    for(int i=0;i++<(int)cvx.size();)
    {
        for(pi&t:smlst[i])
            sum[t.fi]+=t.se;
        for(int&id:idlst[i])
            for(int j=0;j<60;j++)
                ans[id]+=sum[lst[id][j]];
        for(pi&t:smlst[i])
            sum[t.fi]-=t.se;
    }
    for(int i=0;i<q;i++)
        cout<<ans[i]<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 11 ms 10472 KB Output is correct
3 Correct 9 ms 10452 KB Output is correct
4 Correct 22 ms 10456 KB Output is correct
5 Correct 21 ms 10464 KB Output is correct
6 Correct 13 ms 10456 KB Output is correct
7 Correct 13 ms 10436 KB Output is correct
8 Correct 13 ms 10452 KB Output is correct
9 Correct 13 ms 10400 KB Output is correct
10 Correct 14 ms 10396 KB Output is correct
11 Correct 13 ms 10452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 506 ms 80348 KB Output is correct
2 Correct 520 ms 80432 KB Output is correct
3 Correct 2037 ms 93844 KB Output is correct
4 Correct 2033 ms 93708 KB Output is correct
5 Correct 1126 ms 89036 KB Output is correct
6 Correct 1177 ms 89104 KB Output is correct
7 Correct 1220 ms 89028 KB Output is correct
8 Correct 1134 ms 89212 KB Output is correct
9 Correct 1123 ms 89216 KB Output is correct
10 Correct 1144 ms 88892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 254 ms 45840 KB Output is correct
3 Correct 287 ms 45808 KB Output is correct
4 Correct 823 ms 51012 KB Output is correct
5 Correct 835 ms 50980 KB Output is correct
6 Correct 471 ms 48984 KB Output is correct
7 Correct 445 ms 49056 KB Output is correct
8 Correct 466 ms 49060 KB Output is correct
9 Correct 454 ms 48904 KB Output is correct
10 Correct 431 ms 49008 KB Output is correct
11 Correct 453 ms 49080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 11 ms 10472 KB Output is correct
3 Correct 9 ms 10452 KB Output is correct
4 Correct 22 ms 10456 KB Output is correct
5 Correct 21 ms 10464 KB Output is correct
6 Correct 13 ms 10456 KB Output is correct
7 Correct 13 ms 10436 KB Output is correct
8 Correct 13 ms 10452 KB Output is correct
9 Correct 13 ms 10400 KB Output is correct
10 Correct 14 ms 10396 KB Output is correct
11 Correct 13 ms 10452 KB Output is correct
12 Correct 506 ms 80348 KB Output is correct
13 Correct 520 ms 80432 KB Output is correct
14 Correct 2037 ms 93844 KB Output is correct
15 Correct 2033 ms 93708 KB Output is correct
16 Correct 1126 ms 89036 KB Output is correct
17 Correct 1177 ms 89104 KB Output is correct
18 Correct 1220 ms 89028 KB Output is correct
19 Correct 1134 ms 89212 KB Output is correct
20 Correct 1123 ms 89216 KB Output is correct
21 Correct 1144 ms 88892 KB Output is correct
22 Correct 5 ms 9684 KB Output is correct
23 Correct 254 ms 45840 KB Output is correct
24 Correct 287 ms 45808 KB Output is correct
25 Correct 823 ms 51012 KB Output is correct
26 Correct 835 ms 50980 KB Output is correct
27 Correct 471 ms 48984 KB Output is correct
28 Correct 445 ms 49056 KB Output is correct
29 Correct 466 ms 49060 KB Output is correct
30 Correct 454 ms 48904 KB Output is correct
31 Correct 431 ms 49008 KB Output is correct
32 Correct 453 ms 49080 KB Output is correct
33 Correct 701 ms 81984 KB Output is correct
34 Correct 741 ms 81908 KB Output is correct
35 Correct 3540 ms 94684 KB Output is correct
36 Correct 3664 ms 94648 KB Output is correct
37 Correct 1914 ms 90156 KB Output is correct
38 Correct 1848 ms 90228 KB Output is correct
39 Correct 1857 ms 90036 KB Output is correct
40 Correct 1846 ms 90000 KB Output is correct
41 Correct 1834 ms 90216 KB Output is correct
42 Correct 1846 ms 90236 KB Output is correct