답안 #533051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533051 2022-03-04T14:49:59 Z Farhan_HY Trampoline (info1cup20_trampoline) C++14
0 / 100
2000 ms 117912 KB
#include <bits/stdc++.h>
#define int long long
#define float double
#define pb push_back
#define F first
#define S second
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int inf = 8e18;
const int N = 1e6 + 6;
const int M = 1e3 + 3;
const int LOG = 31;
const int mod = 1e9 + 7;
const float pi = atan(1) * 4;
map<int, set<int>> mp;
map<int, set<int>> rmp;
map<int, map<int, int>> num;
map<int, int> getx;
int n, c, r;
int sparce[N][LOG + 1];

void build()
{
    for(auto y: mp)
    {
        for(auto x: y.S)
            sparce[num[y.F][x]][0] = num[y.F - 1][-*rmp[y.F - 1].lower_bound(-x)];
    }
    for(int j = 1; j <= LOG; j++)
    {
        for(auto y: mp)
        {
            for(auto x: y.S)
            {
                int me = num[y.F][x];
                int xx = sparce[me][j - 1];
                sparce[me][j] = sparce[xx][j - 1];
            }
        }
    }
}

main()
{
    IOS
    cin >> r >> c >> n;
    for(int i = 1; i <= n; i++)
    {
        int x, y;
        cin >> y >> x;
        getx[i] = x;
        mp[y].insert(x);
        rmp[y].insert(-x);
        num[y][x] = i;
    }
    build();
    T
    {
        int y, x, yy, xx;
        cin >> y >> x >> yy >> xx;
        if (y == yy)
        {
            cout << "Yes\n";
            continue;
        }
        auto stop = rmp[yy - 1].lower_bound(-xx);
        auto start = mp[y].lower_bound(x);
        if (stop == rmp[yy - 1].end() || start == mp[y].end())
        {
            cout << "No\n";
            continue;
        }
        x = *start;
        xx = -*stop;
        yy--;
        int me = num[yy][xx];
        int j = LOG - 1;
        while((1 << j) > yy - y)
            j--;
        while(yy > y)
        {
            yy -= (1 << j);
            xx = sparce[me][j];
            xx = getx[xx];
            me = num[yy][xx];
            if (me == 0)
            {
                y = -inf;
                x = -inf;
                break;
            }
            j--;
            if (j < 0)
                j++;
        }
        if (xx >= x)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}

Compilation message

trampoline.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 4456 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1951 ms 95144 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2093 ms 99504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 2636 KB expected NO, found YES [11th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2074 ms 117912 KB Time limit exceeded
2 Halted 0 ms 0 KB -