Submission #881144

# Submission time Handle Problem Language Result Execution time Memory
881144 2023-11-30T16:43:01 Z HoriaHaivas Trampoline (info1cup20_trampoline) C++14
0 / 100
2 ms 6748 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;
    fin >> row >> col >> n;
    for (j=1; j<=n; j++)
    {
        fin >> v[j].l >> v[j].c;
        v[j].indice=j;
    }
    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].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]];
        }
    }
    fin >> t;
    for (j=1; j<=t; j++)
    {
        fin >> x1 >> y1 >> x2 >> y2;
        if (x1==x2 && y1<=y2)
        {
            fout << "Yes\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)
                {
                    fout << "Yes\n";
                    continue;
                }
                else
                {
                    fout << "No\n";
                    continue;
                }
            }
            else
            {
                i=nivel[mp2[x1]][r].indice;
                pas=17;
                while(pas)
                {
                    if (v[up[pas][i]].l+1<=x2)
                        i=up[pas][i];
                    pas--;
                }
                if (v[i].l+1==x2 && v[i].c<=y2)
                {
                    fout << "Yes\n";
                    continue;
                }
                else
                {
                    fout << "No\n";
                    continue;
                }
            }
        }
        else
        {
            if (x1==x2 && y1<=y2)
            {
                fout << "Yes\n";
                continue;
            }
            else
            {
                fout << "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:113:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<trambuline_dorian_popa>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |                 if (r+pas<nivel[mp2[x1]].size() && y1>nivel[mp2[x1]][r+pas].c)
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:118:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<trambuline_dorian_popa>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |             if (r==nivel[mp2[x1]].size())
      |                 ~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6748 KB Answer contains longer sequence [length = 200], but output contains 0 elements
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6748 KB Answer contains longer sequence [length = 4000], but output contains 0 elements
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6744 KB Answer contains longer sequence [length = 200000], but output contains 0 elements
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6748 KB Answer contains longer sequence [length = 5000], but output contains 0 elements
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6744 KB Answer contains longer sequence [length = 200000], but output contains 0 elements
2 Halted 0 ms 0 KB -