답안 #646043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646043 2022-09-28T14:19:33 Z victor_gao Jail (JOI22_jail) C++17
0 / 100
1 ms 340 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 120015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int n,m,s1[N],s2[N];
pii pos[N];
vector<pii>v1,v2;
signed main(){
    fast
    int q; cin>>q;
    while (q--){
        cin>>n;
        v1.clear(); v2.clear();
        for (int i=0;i<=n+5;i++){
            s1[i]=0; s2[i]=0;
        }
        for (int i=1;i<n;i++){
            int a,b; cin>>a>>b;
        }
        cin>>m;
        for (int i=1;i<=m;i++){
            cin>>pos[i].x>>pos[i].y;
            if (pos[i].x<pos[i].y){
                s1[pos[i].x]++;
                s1[pos[i].y+1]--;
                v1.push_back(pos[i]);
            }
            else {
                s2[pos[i].x-1]--;
                s2[pos[i].y]++;
                v2.push_back(pos[i]);
            }
        }
        for (int i=1;i<=n;i++)
            s1[i]+=s1[i-1];
        for (int i=n;i>=1;i--)
            s2[i]+=s2[i+1];
        bool flag=1;
        for (int i=1;i<=n;i++){
            if (s1[i]&&s2[i]) flag=0;
        }
        sort(v1.begin(),v1.end());
        sort(v2.begin(),v2.end());
        int mx=0;
        for (auto i:v1){
            if (mx>i.y) flag=0;
            mx=i.y;
        }
        mx=0;
        for (auto i:v2){
            if (mx>i.y) flag=0;
            mx=i.y;
        }
        if (flag) cout<<"Yes\n";
        else cout<<"No\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 0 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -