QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#423402#8730. ParticijaCrysfly7 12ms5748kbC++171.4kb2024-05-27 23:42:422024-05-27 23:42:42

Judging History

你现在查看的是最新测评结果

  • [2024-05-27 23:42:42]
  • 评测
  • 测评结果:7
  • 用时:12ms
  • 内存:5748kb
  • [2024-05-27 23:42:42]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

int op;
int n,a[maxn],b[maxn];

int f[maxn];

int v1[maxn],v2[maxn];
int calc(int *a,int s){
	For(i,1,n) v1[i]=v2[i]=0;
	For(i,1,n) if(s>>(i-1)&1) v1[a[i]]=1; else v2[a[i]]=1;
	int res=0;
	For(i,1,n){
		if(v1[i] && v2[i]) return inf;
		if(v1[i]) res+=1;
	}
	return res;
}

void work()
{
	n=read();
	For(i,1,n)a[i]=read();
	For(i,1,n)b[i]=read();
	int res=inf;
	For(s,0,(1<<n)-1) res=min(res,calc(a,s)+calc(b,(1<<n)-1-s));
	cout<<res<<"\n";
}

signed main()
{
	int T=read();op=read();
	while(T--)work();
	return 0;
}
/*
6 8
2 3
2 4
2 5
3 6
1 6
1 2
1 4
1 5

*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 12ms
memory: 5700kb

input:

751 0
5
5 5 5 5 5
1 2 3 4 5
6
1 2 2 6 4 5
3 6 3 4 3 3
8
5 8 6 5 4 3 6 6
3 4 4 3 2 6 6 2
5
1 1 1 1 1
5 5 4 3 3
8
5 7 3 7 8 2 7 5
4 2 6 3 6 2 5 6
8
5 8 7 3 4 6 5 2
3 3 3 3 3 3 1 3
6
2 1 3 1 3 6
5 5 3 6 3 5
8
8 6 2 4 7 7 4 1
7 7 3 3 7 7 3 3
5
2 1 4 4 2
1 2 1 4 1
6
2 2 2 2 2 2
5 3 2 1 4 6
7
4 1 7 4 2 3 ...

output:

1
3
4
1
4
2
3
2
3
1
4
1
1
4
3
4
3
2
3
4
3
2
3
3
1
2
3
2
1
3
4
2
1
2
4
3
3
4
3
2
1
2
3
3
2
1
3
3
4
3
2
2
3
1
1
3
2
2
3
2
3
1
3
3
4
4
3
2
1
3
1
1
1
4
3
2
3
1
2
1
2
1
3
2
1
2
2
2
3
1
2
1
2
3
1
3
2
3
2
4
4
1
2
3
4
3
2
2
3
2
3
3
3
4
3
1
3
5
2
2
4
2
3
1
3
1
1
2
1
2
3
4
3
2
3
1
1
3
3
2
3
3
2
4
3
5
3
3
3
4
...

result:

ok 751 numbers

Subtask #2:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Test #2:

score: 0
Time Limit Exceeded

input:

10000 0
1
1
1
22
3 20 22 15 8 18 14 19 15 11 18 15 15 19 20 14 10 20 19 4 18 20
22 19 9 17 2 17 8 9 22 22 8 2 15 9 19 6 15 17 9 22 22 1
6
4 1 4 1 4 4
2 2 3 3 3 2
2
1 1
2 2
65
16 27 7 58 30 4 58 59 30 45 27 58 65 15 20 26 58 48 58 25 4 39 4 16 28 28 28 33 59 30 59 19 48 41 59 58 4 65 25 20 59 42 45 5...

output:


result:


Subtask #3:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 12ms
memory: 5628kb

input:

719 1
8
1 1 2 1 5 1 5 1
2 5 6 1 4 4 8 7
5
5 5 5 5 5
1 4 1 2 5
8
5 2 4 7 8 6 1 3
4 4 4 4 4 4 4 4
7
4 5 5 4 4 5 5
1 7 5 3 6 2 4
5
1 4 4 5 2
1 4 2 1 3
2
1 2
2 1
8
6 8 6 2 8 4 5 6
3 4 7 4 8 8 8 4
8
2 7 2 7 2 2 2 2
3 4 1 3 8 5 7 4
8
3 3 2 8 5 6 4 4
4 7 7 4 7 7 8 7
5
2 4 4 4 4
5 2 3 1 4
6
1 1 1 1 1 1
6 5 ...

output:

3
1
1
2
3
2
4
2
3
2
1
4
2
1
1
2
2
3
3
3
3
1
2
1
1
3
1
3
2
2
3
3
2
1
3
3
4
3
2
2
2
2
2
2
4
4
1
2
3
3
2
1
3
3
3
2
3
3
1
3
2
1
4
2
3
2
2
3
3
3
1
2
2
3
1
3
2
3
2
2
2
2
2
3
1
3
1
2
2
2
3
2
2
1
2
3
1
1
1
4
3
3
1
1
2
1
2
1
1
1
1
2
2
2
3
3
2
3
1
3
1
4
3
1
3
3
2
2
3
2
3
4
2
3
3
2
1
3
2
2
2
2
5
1
1
2
3
3
2
2
...

result:

wrong answer 1st numbers differ - expected: '2', found: '3'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #40:

score: 0
Wrong Answer
time: 8ms
memory: 5748kb

input:

704 2
6
5 3 1 4 4 4
4 5 6 4 5 2
7
1 4 1 4 1 1 1
7 1 4 1 6 7 5
7
5 6 6 5 5 6 6
3 4 6 1 7 3 5
8
8 2 7 4 6 1 3 4
6 6 6 6 6 6 6 6
8
1 3 1 2 8 7 4 1
8 8 8 8 5 1 8 8
8
1 6 2 6 7 3 5 8
7 7 5 8 5 7 5 5
6
6 4 5 3 6 1
3 3 3 3 4 3
7
3 3 7 3 3 3 3
1 4 5 3 6 5 7
5
3 1 5 5 1
5 4 3 5 3
6
4 1 4 2 2 2
6 2 2 1 5 2
6
...

output:

4
2
2
1
3
3
2
2
3
3
2
4
2
2
3
1
2
4
2
2
1
2
2
2
2
4
5
2
2
2
3
4
4
1
2
2
3
3
3
3
3
3
1
2
2
2
2
2
4
3
1
4
2
1
3
1
3
3
3
2
3
2
2
1
2
4
2
3
1
3
2
5
1
3
2
2
3
3
2
3
3
3
2
4
1
2
3
3
3
2
3
3
1
3
1
2
3
4
1
2
3
1
3
1
2
2
4
3
3
2
3
3
1
2
4
2
4
2
3
2
4
2
1
1
2
1
1
3
2
2
3
4
1
1
3
1
3
1
3
2
1
2
2
2
3
2
2
4
2
3
...

result:

wrong answer 2nd numbers differ - expected: '3', found: '2'

Subtask #6:

score: 0
Skipped

Dependency #5:

0%