답안 #334918

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334918 2020-12-10T09:04:13 Z inwbear 기지국 (IOI20_stations) C++14
0 / 100
894 ms 1180 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int nn,co[1005];
bitset<1005>go;
vector<int>v[1005];
void dfs(int N)
{
	go[N]=true;
	co[N]=nn*1000;
	for(int i=0;i<v[N].size();i++)
	{
		if(!go[v[N][i]])
		{
			dfs(v[N][i]);
		}
	}
	co[N]+=nn;
	nn++;
	return;
}
vector<int>label(int n,int k,vector<int>a,vector<int>b)
{
	vector<int>labels(n);
	nn=0;
	for(int i=0;i<1005;i++)v[i].clear(),go[i]=false;
	for(int i=0;i<a.size();i++)
	{
		v[a[i]].pb(b[i]);
		v[b[i]].pb(a[i]);
	}
	dfs(0);
	for(int i=0;i<n;i++)labels[i]=co[i];
	return labels;
}

int find_next_station(int s,int t,vector<int>c)
{
	int ss=s/1000,se=s%1000,ts=t/1000,te=t%1000,re,cs,ce;
	if(ts<=ss&&te>=se)
	{
		for(int i=0;i<c.size();i++)
		{
			cs=c[i]/1000;
			ce=c[i]%1000;
			if(cs<=ss&&ce>=se)re=c[i];
		}
	}
	else
	{
		for(int i=0;i<c.size();i++)
		{
			cs=c[i]/1000;
			ce=c[i]%1000;
			if(ss<=cs&&se>=ce)
			{
				if(cs<=ts&&ce>=te)re=c[i];
			}
		}
	}
	return re;
}

Compilation message

stations.cpp: In function 'void dfs(int)':
stations.cpp:21:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i=0;i<v[N].size();i++)
      |              ~^~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:37:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i=0;i<a.size();i++)
      |              ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   for(int i=0;i<c.size();i++)
      |               ~^~~~~~~~~
stations.cpp:61:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |   for(int i=0;i<c.size();i++)
      |               ~^~~~~~~~~
stations.cpp:71:9: warning: 're' may be used uninitialized in this function [-Wmaybe-uninitialized]
   71 |  return re;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1004
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 364 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=2, label=511994
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 580 ms 1180 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 867 ms 832 KB Output is correct
2 Incorrect 894 ms 948 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 510 ms 1004 KB Wrong query response.
2 Halted 0 ms 0 KB -