답안 #632463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
632463 2022-08-20T05:46:31 Z Mahdi Jail (JOI22_jail) C++17
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef pair<int, int> pii;
typedef long long ll;
const int N=12e4+5;
int n, m, a[N];
vector<pii>b, c;

void sol(){
    cin>>n;
    for(int i=1;i<n;++i){
        int u, v;
        cin>>u>>v;
    }
    cin>>m;
    b.clear();
    c.clear();
    fill(a, a+n, -1);
    bool th=1;
    for(int i=0;i<m;++i){
        int u, v;
        cin>>u>>v;
        if(u<v){
            for(int j=u;j<v;++j){
                if(a[j]==1)
                    th=0;
                a[j]=0;
            }
            b.push_back({u, v});
        }
        else{
            for(int j=v;j<u;++j){
                if(a[j]==0)
                    th=0;
                a[j]=1;
            }
            c.push_back({v, u});
        }
    }
    sort(all(b));
    sort(all(c));
    for(int i=0;i+1<b.size();++i){
        if(b[i].S>b[i+1].S)
            th=0;
    }
    for(int i=0;i+1<c.size();++i){
        if(c[i].S>c[i+1].S)
            th=0;
    }
    if(th)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int T;
    cin>>T;
    while(T--)
        sol();
}

Compilation message

jail.cpp: In function 'void sol()':
jail.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0;i+1<b.size();++i){
      |                 ~~~^~~~~~~~~
jail.cpp:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=0;i+1<c.size();++i){
      |                 ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -