답안 #646037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646037 2022-09-28T14:11:00 Z victor_gao Jail (JOI22_jail) C++17
0 / 100
6 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,vis[N];
pii pos[N];

signed main(){
    fast
    int q; cin>>q;
    while (q--){
        cin>>n;
        for (int i=0;i<=n+5;i++)
            vis[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;
        }
        sort(pos+1,pos+1+m);
        int mx1=0,mx2=0,ok=1;
        for (int i=1;i<=m;i++){
            //if (pos[i].x<pos[i].y){
                if (mx1>pos[i].y) ok=0;
                mx1=max(mx1,pos[i].y);
           // }

        }
        for (int i=1;i<=m;i++){
            for (int j=pos[i].x;j<=pos[i].y;j++) vis[j]=1;
        }
        bool flag=1;
        for (int i=1;i<=m;i++){
            for (int j=pos[i].x;j>pos[i].y;j--){
                if (vis[j]) flag=0;
            }
        }
        if (flag) cout<<"Yes\n";
        else cout<<"No\n";
    }
}

Compilation message

jail.cpp: In function 'int main()':
jail.cpp:35:19: warning: unused variable 'mx2' [-Wunused-variable]
   35 |         int mx1=0,mx2=0,ok=1;
      |                   ^~~
jail.cpp:35:25: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   35 |         int mx1=0,mx2=0,ok=1;
      |                         ^~
# 결과 실행 시간 메모리 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 6 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 268 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 268 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 268 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 268 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 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Incorrect 5 ms 340 KB Output isn't correct
6 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 6 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -