답안 #349153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349153 2021-01-16T20:10:53 Z cheetose Worst Reporter 2 (JOI16_worst_reporter2) C++17
0 / 100
6 ms 7676 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<db, db> Pd;
typedef vector<int> Vi;
typedef Vi Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM=MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

Vi v[200002];
int a[200002],b[200002],c[200002],d[200002];
int A[200002],B[200002],dist[200002];
bool used[200002];
bool bfs(int n){
	queue<int> q;
	bool ok = 0;
	memset(dist, 0, sizeof(dist));
	for(int i=0; i<n; i++){
		if(A[i] == -1 && !dist[i]){
			q.push(i);
			dist[i] = 1;
		}
	}
	while(!q.empty()){
		int x = q.front();
		q.pop();
		for(auto &i : v[x]){
			if(B[i] == -1) ok = 1;
			else if(!dist[B[i]]){
				dist[B[i]] = dist[x] + 1;
				q.push(B[i]);
			}
		}
	}
	return ok;
}
bool dfs(int x){
	if(used[x]) return 0;
	used[x] = 1;
	for(auto &i : v[x]){
		if(B[i] == -1 || (!used[B[i]] && dist[B[i]] == dist[x] + 1 && dfs(B[i]))){
			A[x] = i; B[i] = x;
			return 1;
		}
	}
	return 0;
}
int match(int n){
	memset(A, -1, sizeof(A));
	memset(B, -1, sizeof(B));
	int ret = 0;
	while(bfs(n)){
		memset(used, 0, sizeof(used));
		for(int i=0; i<n; i++) if(A[i] == -1 && dfs(i)) ret++;
	}
	return ret;
}
int main() {
	int n;
	scanf("%d",&n);
	Vi vv;
	fup(i,0,n-1,1)scanf("%d%d",a+i,b+i);
	fup(i,0,n-1,1)scanf("%d%d",c+i,d+i),vv.pb(d[i]);
	reverse(ALL(vv));
	int t=0,p=0;
	fup(i,0,n-1,1){
		fup(j,p,n-1,1){
			if(a[i]==c[j] && b[i]<=d[j])
				v[i].pb(j);
		}
		t=lower_bound(ALL(vv),b[i])-vv.begin();
		t=n-t;
		if(t==i+1)p=i+1;
	}
	printf("%d\n",n-match(n));
}

Compilation message

worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
worst_reporter2.cpp:95:2: note: in expansion of macro 'fup'
   95 |  fup(i,0,n-1,1)scanf("%d%d",a+i,b+i);
      |  ^~~
worst_reporter2.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
worst_reporter2.cpp:96:2: note: in expansion of macro 'fup'
   96 |  fup(i,0,n-1,1)scanf("%d%d",c+i,d+i),vv.pb(d[i]);
      |  ^~~
worst_reporter2.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
worst_reporter2.cpp:99:2: note: in expansion of macro 'fup'
   99 |  fup(i,0,n-1,1){
      |  ^~~
worst_reporter2.cpp:10:30: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
worst_reporter2.cpp:100:3: note: in expansion of macro 'fup'
  100 |   fup(j,p,n-1,1){
      |   ^~~
worst_reporter2.cpp:93:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   93 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
worst_reporter2.cpp:95:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   95 |  fup(i,0,n-1,1)scanf("%d%d",a+i,b+i);
      |                ~~~~~^~~~~~~~~~~~~~~~
worst_reporter2.cpp:96:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   96 |  fup(i,0,n-1,1)scanf("%d%d",c+i,d+i),vv.pb(d[i]);
      |                ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7532 KB Output is correct
2 Correct 5 ms 7532 KB Output is correct
3 Correct 5 ms 7676 KB Output is correct
4 Correct 5 ms 7532 KB Output is correct
5 Incorrect 5 ms 7532 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7532 KB Output is correct
2 Correct 5 ms 7532 KB Output is correct
3 Correct 5 ms 7676 KB Output is correct
4 Correct 5 ms 7532 KB Output is correct
5 Incorrect 5 ms 7532 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7532 KB Output is correct
2 Correct 5 ms 7532 KB Output is correct
3 Correct 5 ms 7676 KB Output is correct
4 Correct 5 ms 7532 KB Output is correct
5 Incorrect 5 ms 7532 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7532 KB Output is correct
2 Correct 5 ms 7532 KB Output is correct
3 Correct 5 ms 7676 KB Output is correct
4 Correct 5 ms 7532 KB Output is correct
5 Incorrect 5 ms 7532 KB Output isn't correct
6 Halted 0 ms 0 KB -