답안 #890782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890782 2023-12-22T03:14:01 Z vjudge1 Jail (JOI22_jail) C++17
5 / 100
104 ms 4924 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define mpa make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define bc back()
#define ar array
#define vll vector<ll> 
using namespace std;/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/
template <class _T>
bool chmin(_T &x, const _T &y){
    if(x>y){
        x=y;
        return true;
    }
    return false;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool flag=false;
    if (x<y){
        x=y;flag|=true;
    }
    return flag;
}
//#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=2e18+7;
const ll mod=1e9+7;
const ll N=1e5+7;
const ld eps=1e-9;
void solve(){
	ll i,q;
	ll n;
	ll a,b;
	cin>>n;
	bool bamboo=true;
	for(i=1;i<n;i++){
		cin>>a>>b;
		if(a+1!=b)bamboo=false;
	}
	if(bamboo){
		cin>>q;
		ll l=0;
		vector<pair<ll,ll>> v;
		for(i=0;i<q;i++){
			cin>>a>>b;
			v.pb({a,b});
		}
		sort(all(v));
		for(i=0;i<q;i++){
			a=v[i].fr,b=v[i].sc;
			if(b<=l){
				cout<<"No"<<endl;
				return;
			}
			l=max(l,b);
		}
		cout<<"Yes"<<endl;
		return;
	}
}
signed main(){
	//start();
    ll t=1;
	cin>>t;
    while(t--) solve();
    return 0;
}
/*
1
6
5 4 3 2 1 0





*/

Compilation message

jail.cpp: In function 'void fre(std::string)':
jail.cpp:43:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jail.cpp:43:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 16 ms 348 KB Output is correct
5 Correct 33 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 47 ms 1460 KB Output is correct
10 Correct 48 ms 1628 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Correct 43 ms 1372 KB Output is correct
13 Correct 68 ms 3272 KB Output is correct
14 Correct 72 ms 3276 KB Output is correct
15 Correct 71 ms 3276 KB Output is correct
16 Correct 104 ms 4744 KB Output is correct
17 Correct 90 ms 3764 KB Output is correct
18 Correct 96 ms 4924 KB Output is correct
19 Correct 73 ms 3528 KB Output is correct
20 Correct 79 ms 3508 KB Output is correct
21 Correct 74 ms 3496 KB Output is correct
22 Correct 73 ms 3640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 16 ms 348 KB Output is correct
5 Correct 33 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 47 ms 1460 KB Output is correct
10 Correct 48 ms 1628 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Correct 43 ms 1372 KB Output is correct
13 Correct 68 ms 3272 KB Output is correct
14 Correct 72 ms 3276 KB Output is correct
15 Correct 71 ms 3276 KB Output is correct
16 Correct 104 ms 4744 KB Output is correct
17 Correct 90 ms 3764 KB Output is correct
18 Correct 96 ms 4924 KB Output is correct
19 Correct 73 ms 3528 KB Output is correct
20 Correct 79 ms 3508 KB Output is correct
21 Correct 74 ms 3496 KB Output is correct
22 Correct 73 ms 3640 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Incorrect 1 ms 348 KB Output isn't correct
27 Halted 0 ms 0 KB -