제출 #685488

#제출 시각아이디문제언어결과실행 시간메모리
685488Farhan_HYTrampoline (info1cup20_trampoline)C++14
0 / 100
2094 ms40468 KiB
#include <bits/stdc++.h>
#define int long long
#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 N = 1e5 + 5;
const int M = 1e3 + 3;
const int inf = 1e18;
const int mod = 1e9 + 7;
int r, c, n, q;
map<int, set<int>> mp;
map<pair<int, int>, int> comNum;

void dfs(int y, int x, int comp) {
    comNum[{y, x}] = comp;
    auto it = mp[y].upper_bound(x);
    if (it != mp[y].end()) dfs(y, *it, comp);
    it = mp[y + 1].lower_bound(x);
    if (it != mp[y + 1].end()) dfs(y + 1, *it, comp);
}

main() {
    IOS
    cin >> r >> c >> n;
    for(int i = 1; i <= n; i++) {
        int y, x;
        cin >> y >> x;
        mp[y].insert(x);
    }
    int comp = 0;
    for(auto y: mp) {
        for(auto x: y.S) {
            if (comNum[{y.F, x}]) continue;
            dfs(y.F, x, ++comp);
        }
    }
    cin >> q;
    while(q--) {
        int y1, x1, y2, x2;
        cin >> y1 >> x1 >> y2 >> x2;
        if (y1 == y2 && x1 <= x2) {
            cout << "Yes\n";
            continue;
        }
        if (x1 > x2) {
            cout << "No\n";
            continue;
        }
        auto it = mp[y1].lower_bound(x1);
        if (it == mp[y1].end()) {
            cout << "No\n";
            continue;
        }
        x1 = *it;
        it = mp[y2].upper_bound(x2);
        if (it != mp[y2].begin()) {
            it--;
            if (comNum[{y1, x1}] == comNum[{y2, *it}]) {
                cout << "Yes\n";
                continue;
            }
        }
        it = mp[y2 - 1].upper_bound(x2);
        if (it != mp[y2 - 1].begin()) {
            it--;
            if (comNum[{y1, x1}] == comNum[{y2 - 1, *it}]) {
                cout << "Yes\n";
                continue;
            }
        }
        cout << "No\n";
    }
}

컴파일 시 표준 에러 (stderr) 메시지

trampoline.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...