贡献 SPJ
查看原帖
贡献 SPJ
174756
ctmydf楼主2021/7/5 10:58

来贡献一发自己写的 SPJ

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
int n,m,Path[1005];
bool G[1005][1005];
main(int argc, char*argv[]){
    registerTestlibCmd(argc,argv);
    string Ans=ans.readToken();
    if(Ans=="no")
	{
		if(ouf.readToken()=="no") quitf(_ok,"Accepted!");
		else quitf(_wa,"No answer,but you gave one.");
	}
	int cnt=0;
	while(!ouf.eof())
	{
		Path[++cnt]=ouf.readInt();
		ouf.readChar();
	}
	if(cnt<4) quitf(_wa,"The size of your cycle is too small!");
	n=inf.readInt(),m=inf.readInt();
	for(int i=1,u,v;i<=m;i++)
	{
		u=inf.readInt(),v=inf.readInt();
		G[u][v]=G[v][u]=true;
	}
	for(int i=2;i<=cnt;i++)
	{
		if(!G[Path[i-1]][Path[i]]) quitf(_wa,"No edge between %d and %d!",Path[i-1],Path[i]);
		for(int j=i-2;j>=((i==cnt)?2:1);j--)
		{
			if(G[Path[j]][Path[i]]) quitf(_wa,"There's an edge between %d and %d!",Path[j],Path[i]);	
		}
	}
	quitf(_ok,"Accepted!");
}

有错误还请指出

2021/7/5 10:58
加载中...