Submission #49020506


Source Code Expand

// LUOGU_RID: 141902603
#include<bits/stdc++.h>
#include<atcoder/maxflow>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)

#ifdef EXODUS
	#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
	#define Debug(...) 0
#endif

//=========================================================================================================
// Something about IO

template<typename T>
void read(T &x){
	x=0;T flg=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}

//=========================================================================================================
// Define the global variables here.

bool membg=0;
constexpr int N=5e3+7;
int n,a[N],b[N],c[N],pos[N<<1],vis[N<<1];

bool memed=0;

//=========================================================================================================
// Code here.

void solve(){
	read(n);
	int vlim=0;
	for(int i=1;i<=n;i++)read(a[i]),vlim=max(vlim,a[i]);
	for(int i=1;i<=n;i++)read(b[i]),vlim=max(vlim,b[i]);
	for(int i=1;i<=n;i++)read(c[i]),vlim=max(vlim,c[i]);
	int s=0,t=2*n+2*vlim+1;
	atcoder::mf_graph<int>G(2*n+2*vlim+2);
	for(int i=1;i<=n;i++){
		if(vis[a[i]]){
			G.add_edge(s,i,1);
			G.add_edge(i,n*2+a[i],1);
			G.add_edge(n*2+vlim+a[i],n+i,1);
			G.add_edge(n+i,t,1);
		}
		else{
			vis[a[i]]=1;
			G.add_edge(i,s,1);
			G.add_edge(n*2+a[i],i,1);
			G.add_edge(n+i,n*2+vlim+a[i],1);
			G.add_edge(t,n+i,1);
		}
		G.add_edge(i,n*2+b[i],1);
		G.add_edge(n*2+vlim+c[i],n+i,1);
	}
	for(int i=1;i<=vlim;i++){
		if(vis[i]){
			pos[i]=G.add_edge(n*2+vlim+i,n*2+i,1);
		}else{
			pos[i]=G.add_edge(n*2+i,n*2+vlim+i,1);
		}
	}
	G.flow(s,t);
	
	auto edge=G.edges();
	vector<int>lis;
	for(int i=1;i<=vlim;i++){
		if(vis[i]!=edge[pos[i]].flow)
			lis.eb(i);
	}
	
	printf("%d\n",(int)lis.size());
	for(auto x:lis)printf("%d ",x);
	printf("\n");
	return;
}


//=========================================================================================================

int main(){
	Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
	int timbg=clock();
	int T=1;
	while(T--)solve();
	int timed=clock();
	Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
	fflush(stdout);
	return 0;
}

Submission Info

Submission Time
Task F - Make Same Set
User EXODUS
Language C++ 20 (gcc 12.2)
Score 1000
Code Size 2707 Byte
Status AC
Exec Time 19 ms
Memory 7824 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:19:28: warning: statement has no effect [-Wunused-value]
   19 |         #define Debug(...) 0
      |                            ^
Main.cpp:99:9: note: in expansion of macro ‘Debug’
   99 |         Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
      |         ^~~~~
Main.cpp:19:28: warning: statement has no effect [-Wunused-value]
   19 |         #define Debug(...) 0
      |                            ^
Main.cpp:104:9: note: in expansion of macro ‘Debug’
  104 |         Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
      |         ^~~~~
Main.cpp:100:13: warning: unused variable ‘timbg’ [-Wunused-variable]
  100 |         int timbg=clock();
      |             ^~~~~
Main.cpp:103:13: warning: unused variable ‘timed’ [-Wunused-variable]
  103 |         int timed=clock();
      |             ^~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 2
AC × 36
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 01_rnd_20.txt, 01_rnd_21.txt, 01_rnd_22.txt, 01_rnd_23.txt, 01_rnd_24.txt, 01_rnd_25.txt, 01_rnd_26.txt, 02_worst_01.txt, 02_worst_02.txt, 02_worst_03.txt, 03_ALL_01.txt, 03_ALL_02.txt, 03_ALL_03.txt, 04_test_01.txt, 04_test_02.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3760 KiB
00_sample_02.txt AC 1 ms 3744 KiB
01_rnd_01.txt AC 8 ms 6956 KiB
01_rnd_02.txt AC 8 ms 6940 KiB
01_rnd_03.txt AC 8 ms 7028 KiB
01_rnd_04.txt AC 8 ms 7524 KiB
01_rnd_05.txt AC 8 ms 6880 KiB
01_rnd_06.txt AC 8 ms 6876 KiB
01_rnd_07.txt AC 8 ms 7532 KiB
01_rnd_08.txt AC 8 ms 7532 KiB
01_rnd_09.txt AC 8 ms 7620 KiB
01_rnd_10.txt AC 8 ms 7524 KiB
01_rnd_11.txt AC 8 ms 7024 KiB
01_rnd_12.txt AC 9 ms 7468 KiB
01_rnd_13.txt AC 8 ms 7020 KiB
01_rnd_14.txt AC 8 ms 7088 KiB
01_rnd_15.txt AC 8 ms 7708 KiB
01_rnd_16.txt AC 7 ms 7428 KiB
01_rnd_17.txt AC 7 ms 7524 KiB
01_rnd_18.txt AC 7 ms 7480 KiB
01_rnd_19.txt AC 7 ms 7528 KiB
01_rnd_20.txt AC 7 ms 7604 KiB
01_rnd_21.txt AC 7 ms 7772 KiB
01_rnd_22.txt AC 7 ms 7796 KiB
01_rnd_23.txt AC 7 ms 7824 KiB
01_rnd_24.txt AC 6 ms 7032 KiB
01_rnd_25.txt AC 6 ms 7096 KiB
01_rnd_26.txt AC 6 ms 7092 KiB
02_worst_01.txt AC 19 ms 7096 KiB
02_worst_02.txt AC 18 ms 7140 KiB
02_worst_03.txt AC 18 ms 7156 KiB
03_ALL_01.txt AC 4 ms 5624 KiB
03_ALL_02.txt AC 3 ms 5624 KiB
03_ALL_03.txt AC 3 ms 5580 KiB
04_test_01.txt AC 1 ms 3780 KiB
04_test_02.txt AC 5 ms 6384 KiB