Submission #202617

# Submission time Handle Problem Language Result Execution time Memory
202617 2020-02-17T10:54:53 Z Fasho Ideal city (IOI12_city) C++14
0 / 100
1000 ms 31764 KB
#include <bits/stdc++.h>
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll mark[1000005],sum,X[1000005],Y[1000005],N;

queue<pair<int,int> > q;

vector<int> v[1000005];
void f(int ind,int l)
{
	q.push({ind,l});
	cout<<ind<<endl;
	while(q.size())
	{
		int a=q.front().fi;
		int b=q.front().se;
		q.pop();
		if(mark[a])
			continue;
		mark[a]++;
		if(a<ind)
		{
			sum+=b;
			cout<<a<<sp<<ind<<sp<<b<<endl;
		}
		for(int i=0;i<v[a].size();i++)
		{
			int x=v[a][i];
			if(!mark[x])
				q.push({x,b+1});
		}
	}
}

int  DistanceSum(int N, int *X, int *Y) {
	fast;
	map<pair<int,int>,int> mp;
	for(int i=0;i<N;i++)
	{
		mp[{X[i],Y[i]}]=i+1;
		int x=X[i];
		int y=Y[i];
		if(mp[{x-1,y}]!=0)
		{
			v[i].pb(mp[{x-1,y}]-1);
			v[mp[{x-1,y}]-1].pb(i);
		}
		if(mp[{x+1,y}]!=0)
		{
			v[i].pb(mp[{x+1,y}]-1);
			v[mp[{x+1,y}]-1].pb(i);
		}
		if(mp[{x,y-1}]!=0)
		{
			v[i].pb(mp[{x,y-1}]-1);
			v[mp[{x,y-1}]-1].pb(i);
		}
		if(mp[{x,y+1}]!=0)
		{
			v[i].pb(mp[{x,y+1}]-1);
			v[mp[{x,y+1}]-1].pb(i);
		}
	}
	for(int i=0;i<N;i++)
	{
		// int x=X[i];
		// int y=Y[i];
		for(int j=0;j<N;j++)
			mark[j]=0;
		f(i,0);
	}
	N=sum;
  return N;

}




/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Compilation message

city.cpp: In function 'void f(int, int)':
city.cpp:43:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v[a].size();i++)
               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 202 ms 29512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 29552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 31764 KB Time limit exceeded
2 Halted 0 ms 0 KB -