답안 #566938

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
566938 2022-05-23T06:37:01 Z jamezzz Jail (JOI22_jail) C++17
0 / 100
8 ms 256 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define dbg(...) printf(__VA_ARGS__);
#define getchar_unlocked getchar
#else
#define dbg(...)
#endif
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define mnto(x,y) x=min(x,(__typeof__(x))y)
#define mxto(x,y) x=max(x,(__typeof__(x))y)
#define INF 1023456789
#define LINF 1023456789123456789
#define all(x) x.begin(), x.end()
#define disc(x) sort(all(x));x.resize(unique(all(x))-x.begin());
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vll;
mt19937 rng(time(0));

#define mod 1000000007

inline int add(int a,int b){
	int r=a+b;
	while(r>=mod)r-=mod;
	while(r<0)r+=mod;
	return r;
}

inline int mult(int a,int b){
	return (int)(((ll)(a*b))%mod);
}

inline int rd(){
	int x=0;
	char ch=getchar_unlocked();
	while(!(ch&16))ch=getchar();//keep reading while current character is whitespace
    while(ch&16){//this will break when ‘\n’ or ‘ ‘ is encountered
		x=(x<<3)+(x<<1)+(ch&15);
		ch=getchar_unlocked();
	}
	return x;
}

#define maxn 120000

int pfx[maxn];

int main(){
	int tc;sf("%d",&tc);
	while(tc--){
		int n;sf("%d",&n);
		for(int i=0;i<n-1;++i){
			int a,b;sf("%d%d",&a,&b);
		}
		int m;sf("%d",&m);
		vector<ii> l,r;
		for(int i=0;i<m;++i){
			int s,t;sf("%d%d",&s,&t);
			if(s<t)l.pb({s,t});
			else r.pb({t,s});
		}
		for(int i=1;i<=n;++i)pfx[i]=0;
		sort(all(l));sort(all(r));
		for(ii pr:r)++pfx[pr.fi];
		for(int i=1;i<=n;++i)pfx[i]+=pfx[i-1];
		
		bool die=false;
		for(ii pr:l){
			if(pfx[pr.se]-pfx[pr.fi-1]!=0)die=true;
		}
		int far=0;
		for(ii pr:l){
			if(pr.se<=far)die=true;
			far=pr.se;
		}
		
		for(ii pr:r)swap(pr.fi,pr.se);
		sort(all(r),greater<ii>());
		
		far=n+1;
		for(ii pr:r){
			if(far<=pr.se)die=true;
			far=pr.se;
		}
		
		if(die)pf("No\n");
		else pf("Yes\n");
		
	}
}

Compilation message

jail.cpp: In function 'int main()':
jail.cpp:62:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |  int tc;sf("%d",&tc);
      |           ^
jail.cpp:64:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |   int n;sf("%d",&n);
      |           ^
jail.cpp:66:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |    int a,b;sf("%d%d",&a,&b);
      |              ^
jail.cpp:68:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |   int m;sf("%d",&m);
      |           ^
jail.cpp:71:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |    int s,t;sf("%d%d",&s,&t);
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 8 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 240 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Incorrect 5 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 8 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -