Submission #19548673


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second

int n,cnt[4],f[3],g[3],_g[3],_cnt[4];
map<int,bool> p;
map<int,array<int,3>> q;

int getid(array<int,3> a) {
	for(int i=0;i<3;i++) if(a[i]) return i;
	return 3;
}

array<int,3> getarr(int id) {
	return {id==0,id==1,id==2};
}

int main() {
#ifdef LOCAL
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=1,x,y;i<=n;i++) {
		cin>>x>>y;
		p[y]^=1;q[x][y%3]^=1;
	}
	for(auto t:p) if(t.se) ++f[t.fi%3];
	for(auto t:q) {
		auto a=t.se;
		if(a[0]+a[1]+a[2]>=2) a[0]=1-a[0],a[1]=1-a[1],a[2]=1-a[2];
		++_cnt[getid(a)];_g[0]+=a[0];_g[1]+=a[1];_g[2]+=a[2];
	}
	int ans=1e9;
	for(int s=0;s<16;s++)
		if(!__builtin_parity(s)) {
			memcpy(cnt,_cnt,sizeof(cnt));
			memcpy(g,_g,sizeof(g));
			bool fl=1;
			for(int i=0;i<4;i++)
				if(s>>i&1) {
					if(!cnt[i]) { fl=0;break; }
					--cnt[i];
					auto tmp=getarr(i);
					for(int j=0;j<3;j++) g[j]+=1-2*tmp[j];
				}
			if(!fl) continue;
			int val=max(f[0],g[0])+max(f[1],g[1])+max(f[2],g[2]);
			ans=min(ans,val);
			for(int i=0;i<3;i++)
				if(g[i]>f[i]) {
					int tmp=min({g[i]-f[i],cnt[i],f[0]-g[0],f[1]-g[1],f[2]-g[2]});
					ans=min(ans,val-tmp);break;
				}
		}
	cout<<ans;
	return 0;
}

Submission Info

Submission Time
Task C - Flipper
User newbie314159
Language C++ (GCC 9.2.1)
Score 0
Code Size 1416 Byte
Status WA
Exec Time 68 ms
Memory 9592 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1300
Status
AC × 1
AC × 23
WA × 35
Set Name Test Cases
Sample example0.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, example0.txt
Case Name Status Exec Time Memory
000.txt WA 40 ms 5372 KB
001.txt AC 2 ms 3564 KB
002.txt WA 23 ms 4672 KB
003.txt WA 50 ms 6012 KB
004.txt WA 34 ms 5748 KB
005.txt AC 18 ms 4376 KB
006.txt AC 46 ms 6664 KB
007.txt AC 42 ms 5432 KB
008.txt WA 31 ms 6340 KB
009.txt WA 53 ms 7564 KB
010.txt AC 33 ms 4984 KB
011.txt AC 68 ms 9072 KB
012.txt AC 15 ms 4140 KB
013.txt AC 27 ms 5464 KB
014.txt AC 14 ms 4164 KB
015.txt AC 46 ms 6204 KB
016.txt AC 44 ms 6100 KB
017.txt AC 3 ms 3620 KB
018.txt AC 10 ms 3688 KB
019.txt WA 21 ms 4280 KB
020.txt AC 31 ms 5316 KB
021.txt WA 20 ms 4740 KB
022.txt WA 23 ms 5364 KB
023.txt WA 10 ms 4176 KB
024.txt AC 33 ms 5808 KB
025.txt AC 2 ms 3460 KB
026.txt WA 19 ms 3560 KB
027.txt AC 19 ms 3568 KB
028.txt WA 18 ms 3612 KB
029.txt WA 17 ms 3500 KB
030.txt AC 19 ms 3504 KB
031.txt WA 19 ms 3500 KB
032.txt WA 56 ms 8804 KB
033.txt WA 57 ms 8776 KB
034.txt AC 56 ms 8440 KB
035.txt WA 61 ms 9592 KB
036.txt WA 57 ms 9008 KB
037.txt WA 58 ms 9124 KB
038.txt WA 60 ms 9268 KB
039.txt WA 57 ms 9540 KB
040.txt WA 58 ms 8772 KB
041.txt WA 59 ms 9072 KB
042.txt WA 55 ms 9120 KB
043.txt WA 60 ms 9160 KB
044.txt WA 57 ms 8816 KB
045.txt WA 55 ms 9056 KB
046.txt WA 57 ms 9280 KB
047.txt WA 59 ms 8912 KB
048.txt WA 59 ms 9260 KB
049.txt WA 57 ms 8828 KB
050.txt WA 58 ms 9244 KB
051.txt WA 60 ms 9084 KB
052.txt WA 57 ms 8888 KB
053.txt WA 56 ms 9124 KB
054.txt AC 60 ms 8244 KB
055.txt AC 59 ms 8340 KB
056.txt AC 56 ms 8692 KB
example0.txt AC 2 ms 3528 KB