Submission #890811

# Submission time Handle Problem Language Result Execution time Memory
890811 2023-12-22T03:42:55 Z vjudge1 Jail (JOI22_jail) C++17
0 / 100
6 ms 348 KB
/*
 
author : abushbandit
contest : ---
 
*/
 
#include "bits/stdc++.h"
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
 
using namespace std;
 
#define int long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define pb push_back
#define rep(i,s,f) for(int i = s;i < f;i++)
 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
#pragma GCC optimize("Ofast,no-stack-protector,fast-math",3)
 
template <class type1>
	using ordered_multiset = tree <type1, null_type, less_equal <type1>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
const ll INF = 1e18;
const ll MOD7 = 1e9 + 7;
const ll MOD9 = 998244353;
const ld PI = acos(-1.0);
const int N = 1e6 + 6;
 
template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}
 
template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
    
}
 
int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
	}
	return res;
}
 
void start_file(string file){
	freopen((file + ".in").c_str(),"r",stdin);
	freopen((file + ".out").c_str(),"w",stdout);
}

void solve() {
	
	int q;
	cin >> q;
	for(int i = 0;i < q;i++){
		int n;
		cin >> n;
		bool bamboo = 1;
		//~ vector<vector<int>> g(n + 1);
		for(int j = 0;j < n - 1;j++){
			int a,b;
			cin >> a >> b;
			if(a == j + 1 && b == j + 2){
				
			} else{
				bamboo = 0;
			}
		}
		int m;
		cin >> m;
		int s[m],t[m];
		vector<pair<int,int>> a;
		for(int j = 0;j < m;j++){
			cin >> s[j] >> t[j];
			a.pb({s[j],t[j]});
		}
		bool check = 0;
		sort(all(a));
		for(int j = 0;j < m - 1;j++){
			if(a[j].ss > a[j].ff){
				if(a[j + 1].ss < a[j + 1].ff){
					if(a[j + 1].ss < a[j].ss){
						cout << "No\n";
						check = 1;
						break;
					}
				}
			}
			if(min(a[j].ff,a[j].ss) <= min(a[j + 1].ff,a[j + 1].ss) && max(a[j].ff,a[j].ss) >= max(a[j + 1].ff,a[j + 1].ss)){
				cout << "No\n";
				check = 1;
				break;
			}
		}
		if(!check){
			cout << "Yes\n";
		}
		
	}
	
}

signed main() {
	
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	
	int t = 1;
//	cin >> t;
	while(t--){
		solve();
	}
 
}

Compilation message

jail.cpp: In function 'void solve()':
jail.cpp:86:8: warning: variable 'bamboo' set but not used [-Wunused-but-set-variable]
   86 |   bool bamboo = 1;
      |        ^~~~~~
jail.cpp: In function 'void start_file(std::string)':
jail.cpp:75:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |  freopen((file + ".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jail.cpp:76:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |  freopen((file + ".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 6 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 3 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 6 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -