QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#75009#5446. 琪露诺的符卡交换XZTmaxsmall67Compile Error//C++231.3kb2023-02-04 14:16:202023-02-04 14:16:28

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:16:28]
  • 评测
  • [2023-02-04 14:16:20]
  • 提交

answer

#include<bits/stdc++.h>
#define pii pair<int,int>
#pragrama optimize(2)
#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];
multiset<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));
		int res=0;
		for(int i=1;i<=n;i++)
		{
			memset(vis,0,sizeof(vis));
			res+=dfs(i);
		}
		for(int i=1;i<=n;i++)
		{
			e[i].erase(e[i].find(ch[i]));e[ch[i]].erase(e[ch[i]].find(i));
			for(int j=1;j<=n;j++)
				if(ch[i]-n==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

answer.code:3:2: error: invalid preprocessing directive #pragrama; did you mean #pragma?
    3 | #pragrama optimize(2)
      |  ^~~~~~~~
      |  pragma
answer.code: In function ‘void work()’:
answer.code:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code:38:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |                         scanf("%d",&a[i][j]);
      |                         ~~~~~^~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:70:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   70 |         int _;scanf("%d",&_);
      |               ~~~~~^~~~~~~~~