Submission #349140

# Submission time Handle Problem Language Result Execution time Memory
349140 2021-01-16T19:32:50 Z cheetose None (JOI16_worst_reporter2) C++17
0 / 100
4 ms 7532 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);
	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);
	fup(i,0,n-1,1){
		fup(j,0,n-1,1){
			if(a[i]==c[j] && b[i]<=d[j])v[i].pb(j);
		}
	}
	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:94:2: note: in expansion of macro 'fup'
   94 |  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:95:2: note: in expansion of macro 'fup'
   95 |  fup(i,0,n-1,1)scanf("%d%d",c+i,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:96:2: note: in expansion of macro 'fup'
   96 |  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:97:3: note: in expansion of macro 'fup'
   97 |   fup(j,0,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:94:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   94 |  fup(i,0,n-1,1)scanf("%d%d",a+i,b+i);
      |                ~~~~~^~~~~~~~~~~~~~~~
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",c+i,d+i);
      |                ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7532 KB Output isn't correct
2 Halted 0 ms 0 KB -