/ Randle /

记录详情

Runtime Error


  
# 状态 耗时 内存占用
#1 Time Exceeded ≥3014ms ≥364.0 KiB
#2 Time Exceeded ≥3011ms ≥344.0 KiB
#3 Time Exceeded ≥3009ms ≥256.0 KiB
#4 Time Exceeded ≥3011ms ≥256.0 KiB
#5 Time Exceeded ≥3011ms ≥384.0 KiB
#6 Time Exceeded ≥3014ms ≥384.0 KiB
#7 Time Exceeded ≥3007ms ≥384.0 KiB
#8 Time Exceeded ≥3008ms ≥492.0 KiB
#9 Time Exceeded ≥3007ms ≥600.0 KiB
#10 Time Exceeded ≥3007ms ≥384.0 KiB
#11 Runtime Error 5ms 464.0 KiB
#12 Runtime Error 4ms 484.0 KiB
#13 Runtime Error 7ms 384.0 KiB
#14 Runtime Error 5ms 460.0 KiB
#15 Runtime Error 6ms 384.0 KiB
#16 Runtime Error 6ms 384.0 KiB
#17 Runtime Error 6ms 488.0 KiB
#18 Runtime Error 6ms 384.0 KiB
#19 Runtime Error 6ms 512.0 KiB
#20 Runtime Error 3ms 512.0 KiB

代码

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
#define N 3010
struct node
{
    int to,nxt,w;
}edge[N<<2];
int k=0;
int head[N];
int n,m,q;
char s[11];
void add(int u,int v,int w)
{
    edge[++k].to=v;
    edge[k].w=w;
    edge[k].nxt=head[u];
    head[u]=k;
}
bool vis[N];
int dfs(int x,int p)
{
	int ans2=99999;
	for(int i=head[x];i;i=edge[i].nxt)
	{
		int v=edge[i].to;
		int w=edge[i].w;
		if(!vis[v])
		{
			
			if(v==p)
			{
				ans2=min(w,ans2);
				
			}
			else
			{
				vis[v]=true;
				int f;
				f=dfs(v,p);
				vis[v]=false;
				ans2=min(ans2,max(w,f));
			}
		}
	}
	return ans2;
}
int read()
{
	int x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int main()
{

	cin>>n>>m;
	
	for(int i=1;i<=m;i++)
	{
		int x,y,w;
	    x=read();
	    y=read();
	    w=read();
		add(x,y,w);
		add(y,x,w);
	}
    cin>>q;
    if(n>3100)
    {
    	while(q--)
    	{
    		cout<<"Baozika"<<endl;
		}
		return 0;
	}
    while(q--)
    {
    	memset(vis,false,sizeof(vis));
    	cin>>s;
    	if(s[0]=='g')
    	{
    		int s1,s2,t1,t2;
    		s1=read();
    		t1=read();
    		s2=read();
    		t2=read();
    		int wa1=dfs(s1,t1);
    		int wa2=dfs(s2,t2);

    		if(wa1==wa2)
    		{
    			cout<<"Baozika"<<endl;
			}
			else
			{
				cout<<"madoka"<<endl;
			}
		}
		else
		{
			int x,y,w;
			cin>>x>>y>>w;
			add(x,y,w);
			add(y,x,w);
		}
	}
    
	
}

信息

递交者
类型
递交
题目
玩游戏(CQ直辖市noip模拟赛联考) T2
题目数据
下载
语言
C++
递交时间
2017-11-04 20:22:34
评测时间
2017-11-04 20:22:34
评测机
分数
0
总耗时
30163ms
峰值内存
600.0 KiB