Submission #881610

# Submission time Handle Problem Language Result Execution time Memory
881610 2023-12-01T15:35:13 Z HoriaHaivas Trampoline (info1cup20_trampoline) C++14
100 / 100
507 ms 59176 KB
/*
    "care a facut teste cu Lattice reduction attack e ciudat"
    "linistiti va putin"
    - 2023 -
*/
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize("Ofast")

using namespace std;

struct trambuline_dorian_popa
{
    int indice;
    int l;
    int c;
    int lnorm;
};

bool cmp(trambuline_dorian_popa a, trambuline_dorian_popa b)
{
    return a.l<b.l;
}

bool cmp2(trambuline_dorian_popa a, trambuline_dorian_popa b)
{
    return a.c<b.c;
}

trambuline_dorian_popa v[200001];
int up[18][200001];
vector<trambuline_dorian_popa> nivel[200001];
unordered_map<int,int> mp;
unordered_map<int,int> mp2;

int main()
{
    ifstream fin("secvp.in");
    ofstream fout("secvp.out");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,t,i,j,row,col,x,r,pas,x1,y1,x2,y2;
    cin >> row >> col >> n;
    for (j=1; j<=n; j++)
    {
        cin >> v[j].l >> v[j].c;
    }
    sort(v+1,v+1+n,cmp);
    x=0;
    for (j=1; j<=n; j++)
    {
        if (j==1 || v[j].l!=v[j-1].l)
        {
            if (x!=0)
                sort(nivel[x].begin(),nivel[x].end(),cmp2);
            x++;
        }
        v[j].indice=j;
        v[j].lnorm=x;
        nivel[x].push_back(v[j]);
        mp[x]=v[j].l;
        mp2[v[j].l]=x;
    }
    sort(nivel[x].begin(),nivel[x].end(),cmp2);
    for (j=1; j<=n; j++)
    {
        if (mp2[v[j].l+1]==v[j].lnorm+1)
        {
            r=-1;
            pas=(1<<17);
            while (pas)
            {
                if (r+pas<nivel[v[j].lnorm+1].size() && v[j].c>nivel[v[j].lnorm+1][r+pas].c)
                    r+=pas;
                pas=pas/2;
            }
            r++;
            if (r==nivel[v[j].lnorm+1].size())
                up[0][j]=j;
            else
                up[0][j]=nivel[v[j].lnorm+1][r].indice;
        }
        else
        {
            up[0][j]=j;
        }
    }
    for (j=1; j<=17; j++)
    {
        for (i=1; i<=n; i++)
        {
            up[j][i]=up[j-1][up[j-1][i]];
        }
    }
    cin >> t;
    for (j=1; j<=t; j++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1==x2 && y1<=y2)
        {
            cout << "Yes\n";
            continue;
        }
        if (x1>x2 || y1>y2)
        {
            cout << "No\n";
            continue;
        }
        if (mp2[x1]!=0)
        {
            r=-1;
            pas=(1<<17);
            while(pas)
            {
                if (r+pas<nivel[mp2[x1]].size() && y1>nivel[mp2[x1]][r+pas].c)
                    r+=pas;
                pas=pas/2;
            }
            r++;
            if (r==nivel[mp2[x1]].size())
            {
                if (x1==x2 && y1<=y2)
                {
                    cout << "Yes\n";
                    continue;
                }
                else
                {
                    cout << "No\n";
                    continue;
                }
            }
            else
            {
                i=nivel[mp2[x1]][r].indice;
                pas=17;
                while(pas>=0)
                {
                    if (v[up[pas][i]].l+1<=x2)
                        i=up[pas][i];
                    pas--;
                }
                if (v[i].l+1==x2 && v[i].c<=y2)
                {
                    cout << "Yes\n";
                    continue;
                }
                else
                {
                    cout << "No\n";
                    continue;
                }
            }
        }
        else
        {
            if (x1==x2 && y1<=y2)
            {
                cout << "Yes\n";
                continue;
            }
            else
            {
                cout << "No\n";
                continue;
            }
        }
    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:75:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<trambuline_dorian_popa>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |                 if (r+pas<nivel[v[j].lnorm+1].size() && v[j].c>nivel[v[j].lnorm+1][r+pas].c)
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:80:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<trambuline_dorian_popa>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |             if (r==nivel[v[j].lnorm+1].size())
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:117:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<trambuline_dorian_popa>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  117 |                 if (r+pas<nivel[mp2[x1]].size() && y1>nivel[mp2[x1]][r+pas].c)
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:122:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<trambuline_dorian_popa>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  122 |             if (r==nivel[mp2[x1]].size())
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 21340 KB 200 token(s): yes count is 21, no count is 179
2 Correct 6 ms 21340 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 21340 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 63 ms 29440 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 63 ms 29416 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 62 ms 27728 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 63 ms 29268 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 394 ms 38976 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 434 ms 38644 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 411 ms 37988 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 440 ms 39232 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 507 ms 39116 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 486 ms 44976 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 8 ms 21592 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 8 ms 21596 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 10 ms 22108 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 8 ms 21596 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 21728 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 10 ms 21596 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 410 ms 46100 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 419 ms 40948 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 363 ms 38188 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 471 ms 59176 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 418 ms 45288 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 365 ms 39140 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 410 ms 38796 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 381 ms 38364 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 432 ms 44992 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 445 ms 44880 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 461 ms 50824 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 381 ms 38000 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 381 ms 38956 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 355 ms 39292 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 342 ms 38940 KB 200000 token(s): yes count is 129674, no count is 70326