답안 #99787

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99787 2019-03-07T09:51:52 Z MvC 장난감 기차 (IOI17_train) C++11
0 / 100
1943 ms 1560 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=5e3+50;
const int mod=1e9+7;
using namespace std;
int n,i,m,ans,viz[nmax],x,y,a[nmax],r[nmax],nr;
vector<int>v[nmax];
void dfs(int x)
{
	if(!viz[x])viz[x]=1;
	else if(viz[x]==2)return;
	else if(viz[x]==1)
	{
		if(nr>0)ans=1;
		return;
	}
	nr+=r[x];
	for(int i=0;i<v[x].size();i++)
	{
		dfs(v[x][i]);
	}
	nr-=r[x];
	viz[x]=2;
}
vector<int> who_wins(vector<int> A,vector<int> R,vector<int> X,vector<int> Y)
{
	n=(int)A.size();
	m=(int)X.size();
	for(i=1;i<=n;i++)a[i]=A[i-1];
	for(i=1;i<=n;i++)r[i]=R[i-1];
	for(i=1;i<=m;i++)
	{
		x=X[i-1],y=Y[i-1];
		x++,y++;
		v[x].pb(y);
	}
	vector<int>rs(n);
	for(i=1;i<=n;i++)
	{
		memset(viz,0,sizeof(viz));
		ans=nr=0;
		dfs(i);
		rs.pb(ans);
	}
	return rs;
}
/*int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)cin>>r[i];
	for(i=1;i<=m;i++)
	{
		cin>>x>>y;
		x++,y++;
		v[x].pb(y);
	}
	for(i=1;i<=n;i++)
	{
		memset(viz,0,sizeof(viz));
		ans=nr=0;
		dfs(i);
		cout<<ans<<" ";
	}
    return 0;
}*/

Compilation message

train.cpp: In function 'void dfs(int)':
train.cpp:30:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v[x].size();i++)
              ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 281 ms 1144 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 216 ms 1528 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1273 ms 1292 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1943 ms 1560 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 281 ms 1144 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -