QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#75004#5446. 琪露诺的符卡交换XZTmaxsmall670 6ms4128kbC++141.2kb2023-02-04 14:12:082023-02-04 14:12:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-04 14:12:32]
  • 评测
  • 测评结果:0
  • 用时:6ms
  • 内存:4128kb
  • [2023-02-04 14:12:08]
  • 提交

answer

#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
#define pb push_back
using namespace std;
const int N=510;
int n;
int vis[N],ch[N];
int a[N][N],ans[N][N];
set<int>e[N];
int dfs(int x)
{
	for(auto y:e[x])
	{
		if(vis[y])continue;vis[y]=1;
		if(!ch[y]||dfs(ch[y]))
		{
			ch[x]=y;ch[y]=x;
			return 1;
		}
	}
	return 0;
}
void work()
{
	scanf("%d",&n);
	for(int i=1;i<=n<<1;i++)
		e[i].clear(),ch[i]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			a[i][j]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			e[a[i][j]+n].insert(i);
			e[i].insert(a[i][j]+n);
		}
	for(int _=1;_<=n;_++)
	{
		memset(ch,0,sizeof(ch));
		for(int i=1;i<=n;i++)
		{
			memset(vis,0,sizeof(vis));
			dfs(i);
		}
		for(int i=1;i<=n;i++)
		{
			e[i].erase(ch[i]);e[ch[i]].erase(i);
			for(int j=1;j<=n;j++)
				if(ch[i]-j==a[i][j])
				{
					a[i][j]=0;ans[i][_]=j;
					break;
				}
		}
	}
	printf("%d\n",n*(n-1)>>1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i<j)printf("%d %d %d %d\n",i,ans[i][j],j,ans[j][i]);
	
}
int main()
{
	int _;scanf("%d",&_);
	while(_--)work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 4128kb

input:

7
132
96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 ...

output:

8646
1 0 2 132
1 0 3 132
1 0 4 132
1 0 5 132
1 0 6 132
1 0 7 132
1 0 8 132
1 0 9 132
1 0 10 132
1 0 11 132
1 0 12 132
1 0 13 132
1 0 14 132
1 0 15 132
1 0 16 132
1 0 17 132
1 0 18 132
1 0 19 132
1 0 20 132
1 0 21 132
1 0 22 132
1 0 23 132
1 0 24 132
1 0 25 132
1 0 26 132
1 0 27 132
1 0 28 132
1 0 29...

result:

wrong answer you swapped a card not existed.

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%