QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#84617#4513. Slide ParadefansizheCompile Error//C++231.5kb2023-03-06 16:20:142023-03-06 16:20:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-06 16:20:44]
  • 评测
  • [2023-03-06 16:20:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> edge[405];
int eid[205][205];
int vis[405];
int ex[5005],ey[5005];
int to[405];
int num[5005];
int mat[205][205];
int nosol;
void dfs(int x){
	vis[x]=1;
	for(int y:edge[x])if(!to[y]){to[x]=y,to[y]=x;return;}
	for(int y:edge[x])if(!vis[y]){
		int z=to[y];to[z]=0;
		vis[y]=1;
		to[x]=y,to[y]=x;
		dfs(z);
		return;
	}
	if(!to[x])nosol=1;
}
stack<int> st;
void solve(int x){
	for(int y=1;y<=n;y++)if(mat[x][y])mat[x][y]--,solve(y);
	st.push(x);
}
int main(){
	int _;scanf("%d",&_);
	for(int __=1;__<=_;__++){
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++)edge[i].clear();
		memset(num,0,sizeof(num));
		memset(to,0,sizeof(to));
		for(int i=1;i<=m;i++){
			int x,y;scanf("%d%d",&x,&y);
			edge[x].push_back(y+n);
			edge[y+n].push_back(x);
			ex[i]=x,ey[i]=y;
			eid[x][y]=i;
		}
		for(int i=1;i<=n;i++){
			memset(vis,0,sizeof(vis));
			dfs(i);
			if(nosol)break;
		}
		if(nosol){printf("Case #%d: IMPOSSIBLE\n",__);nosol=0;continue;}
		for(int i=1;i<=n;i++)num[eid[i][to[i]-n]]++;
		for(int i=1;i<=m;i++)if(!num[i]){
			memset(vis,0,sizeof(vis));
			int x=ex[i],y=ey[i]+n,tx=to[x],ty=to[y];
			to[x]=y,to[y]=x;vis[x]=vis[y]=1;
			to[ty]=to[tx]=0;dfs(tx);
			for(int j=1;j<=n;j++)num[eid[j][to[j]-n]]++;
		}
		for(int i=1;i<=m;i++)mat[ex[i]][ey[i]]=num[i];
		for(int i=1;i<=n;i++)assert(!num[i][i]);
		solve(1);
		printf("Case #%d: %d\n",__,st.size());
		while(!st.empty())printf("%d ",st.top()),st.pop();puts("");
	}
	return 0;
}

详细

In file included from /usr/include/c++/11/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from answer.code:1:
answer.code: In function ‘int main()’:
answer.code:58:52: error: invalid types ‘int[int]’ for array subscript
   58 |                 for(int i=1;i<=n;i++)assert(!num[i][i]);
      |                                                    ^
answer.code:60:36: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘std::stack<int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
   60 |                 printf("Case #%d: %d\n",__,st.size());
      |                                   ~^       ~~~~~~~~~
      |                                    |              |
      |                                    int            std::stack<int>::size_type {aka long unsigned int}
      |                                   %ld
answer.code:30:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         int _;scanf("%d",&_);
      |               ~~~~~^~~~~~~~~
answer.code:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |                 scanf("%d%d",&n,&m);
      |                 ~~~~~^~~~~~~~~~~~~~
answer.code:37:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |                         int x,y;scanf("%d%d",&x,&y);
      |                                 ~~~~~^~~~~~~~~~~~~~