답안 #845223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845223 2023-09-06T12:40:25 Z samekkk Trampoline (info1cup20_trampoline) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a,b) for (int a = 0; a < (b); ++a)
#define pb push_back
#define all(t) t.begin(), t.end()

struct Pole
{
    int y=-1, x=-1;
};

struct Element
{
    int val, idx;
    bool operator < (const Element &element) const
    {
        return val < element.val;
    }
};

const int max_N = 2e5+5;
int wysokosc = 0, szerokosc = 0, n = 0, q = 0, y_1 = 0, y_2 = 0, x_1 = 0, x_2 = 0;
Pole P[max_N];
int nextt[max_N];
map<int,set<Element>> S;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> wysokosc >> szerokosc >> n;
    rep(i,n) cin >> P[i].y >> P[i].x;
    rep(i,n) S[P[i].y].insert({P[i].x,i});
    //for (auto it = S.begin(); it != S.end(); ++it) sort(all(it->second));
    rep(i,n)
    {
        int y = P[i].y, x = P[i].x;
        if (auto it = S.find(y+1) == S.end())
        {
            nextt[i] = -1;
            continue;
        }
        auto it = S[y+1].lower_bound({x,-1});
        if (it != S[y+1].end()) nextt[i] = it->idx;
        else nextt[i] = -1;
    }
    //rep(i,n) cout << nextt[i] << endl;
    cin >> q;
    rep(z,q)
    {
        cin >> y_1 >> x_1 >> y_2 >> x_2;
        if (y_1 > y_2 or x_1 > x_2)
        {
            cout << "No" << '\n';
            continue;
        }
        if (y_1 == y_2)
        {
            cout << "Yes" << '\n';
            continue;
        }
        if (auto it = S.find(y_1) == S.end())
        {
            else cout << "No" << '\n';
            continue;
        }
        if (auto it = S[y_1].lower_bound({x_1,-1}) == S[y_1].end())
        {
            else cout << "No" << '\n';
            continue;
        }
        int akt = (S[y_1].lower_bound({x_1,-1}))->idx, y = P[akt].y, x = P[akt].x;
        bool czy_OK = false;
        while(y < y_2)
        {
            ++y;
            if (y > wysokosc) break;
            if (y == y_2 and x <= x_2)
            {
                czy_OK = true;
                break;
            }
            if (nextt[akt] == -1) break;
            akt = nextt[akt], x = P[akt].x;
        }
        if (czy_OK == true) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
    return 0;
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:41:18: warning: unused variable 'it' [-Wunused-variable]
   41 |         if (auto it = S.find(y+1) == S.end())
      |                  ^~
trampoline.cpp:67:13: error: expected '}' before 'else'
   67 |             else cout << "No" << '\n';
      |             ^~~~
trampoline.cpp:66:9: note: to match this '{'
   66 |         {
      |         ^
trampoline.cpp:65:18: warning: unused variable 'it' [-Wunused-variable]
   65 |         if (auto it = S.find(y_1) == S.end())
      |                  ^~
trampoline.cpp:72:13: error: expected '}' before 'else'
   72 |             else cout << "No" << '\n';
      |             ^~~~
trampoline.cpp:71:9: note: to match this '{'
   71 |         {
      |         ^
trampoline.cpp:70:18: warning: unused variable 'it' [-Wunused-variable]
   70 |         if (auto it = S[y_1].lower_bound({x_1,-1}) == S[y_1].end())
      |                  ^~
trampoline.cpp:73:13: error: continue statement not within a loop
   73 |             continue;
      |             ^~~~~~~~
trampoline.cpp: At global scope:
trampoline.cpp:77:9: error: expected unqualified-id before 'while'
   77 |         while(y < y_2)
      |         ^~~~~
trampoline.cpp:89:9: error: expected unqualified-id before 'if'
   89 |         if (czy_OK == true) cout << "Yes" << '\n';
      |         ^~
trampoline.cpp:90:9: error: expected unqualified-id before 'else'
   90 |         else cout << "No" << '\n';
      |         ^~~~
trampoline.cpp:91:5: error: expected declaration before '}' token
   91 |     }
      |     ^
trampoline.cpp:92:5: error: expected unqualified-id before 'return'
   92 |     return 0;
      |     ^~~~~~
trampoline.cpp:93:1: error: expected declaration before '}' token
   93 | }
      | ^