답안 #685732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
685732 2023-01-24T22:47:17 Z divad Trampoline (info1cup20_trampoline) C++14
19 / 100
2000 ms 17292 KB
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
using namespace std;
int r,c,n,T,x1,x2,y1,y2;
vector<pii> secv;
map<int, set<int>> mp;

ifstream fin("input.txt");

bool trecut(pii s, int x){
    return (s.first >= x || x <= s.second);
}

bool inclus(pii s, int x){
    return (s.first <= x && x <= s.second);
}

int next_pos(int row, int col){
    if(col > *(--mp[row].end())){
        return -1;
    }
    auto it = upper_bound(all(mp[row]), col);
    return *it;
}

void solve(){
    cin >> x1 >> y1 >> x2 >> y2;
    /*cout << x1 << ", " << y1 << " -> " << x2 << ", " << y2 << "\n";
    for(auto it: secv){
        cout << trecut(it, x1) << "\n";
    }*/
    if(x1 > x2 || y1 > y2){
        //cout << (x1 > x2) << " , " << (y1 > y2) << "\n";
        cout << "No\n"; return ;
    }
    if(x1 == x2){
        cout << "Yes\n"; return ;
    }
    int st = 0, dr = secv.size()-1;
    int ans = -1;
    while(st <= dr){
        int mid = ((st+dr)>>1);
        if(trecut(secv[mid], x1)){
            ans = mid;
            dr = mid-1;
        }else{
            st = mid+1;
        }
    }
    if(ans == -1){
        cout << "No\n";
        return ;
    }
    if(!inclus(secv[ans], x2)){
        cout << "No\n"; return ;
    }
    bool ok = true;
    while(x1 < x2){
        y1 = next_pos(x1, y1);
        if(y1 == -1){
            ok = false;
            break;
        }
        x1++;
    }
    if(ok){
        ok = (y1 <= y2);
    }
    cout << (ok ? "Yes" : "No") << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> r >> c >> n;
    for(int i = 1; i <= n; i++){
        cin >> x1 >> y1;
        mp[x1].insert(y1);
    }
    int ind = -1;
    for(auto [row, v]: mp){
        /*cout << row << " = ";
        for(auto it: v){
            cout << it << " ";
        }
        cout << "\n";*/
        if(secv.size() == 0){
            secv.push_back({row, row+1});
            ind++;
        }else{
            if(row == secv[ind].second){
                secv[ind].second = row+1;
            }else{
                secv.push_back({row, row+1});
                ind++;
            }
        }
    }
    /*for(auto [st, dr]: secv){
        cout << st << ", " << dr << "\n";
    }*/
    cin >> T;
    while(T--){
        solve();
    }
    return 0;
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:88:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   88 |     for(auto [row, v]: mp){
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 724 KB expected NO, found YES [34th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1330 ms 10196 KB expected YES, found NO [2299th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 15288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 700 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 110 ms 872 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 7 ms 1352 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 166 ms 940 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 375 ms 988 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 198 ms 1004 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 17292 KB Time limit exceeded
2 Halted 0 ms 0 KB -