답안 #432221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432221 2021-06-18T04:07:20 Z Amylopectin 기지국 (IOI20_stations) C++14
0 / 100
953 ms 784 KB
#include <iostream>
#include <vector>
#include "stations.h"
//#include "stub.cpp"
using namespace std;
const int mxn = 2010;
vector <int> pa[mxn] = {};
int clab[mxn] = {},ru = 0;
int re(int cn,int sta,int be)
{
    int i,fn;
    if(sta == 0)
    {
        clab[cn] = ru;
        ru ++;
    }
    for(i=0; i<pa[cn].size(); i++)
    {
        fn = pa[cn][i];
        if(fn == be)
        {
            continue;
        }
        re(fn,(sta+1)%2,cn);
    }
    if(sta == 1)
    {
        clab[cn] = ru;
        ru ++;
    }
    return 0;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
    int i,j,f,t;
	vector<int> lab(n);
	for(i=0; i<n; i++)
	{
        pa[i].clear();
	}
	for(i=0; i<n-1; i++)
	{
        f = u[i];
        t = v[i];
        pa[f].push_back(t);
        pa[t].push_back(f);
	}
	re(0,0,-1);
	for (i = 0; i < n; i++)
	{
		lab[i] = clab[i];
	}
	return lab;
}

int find_next_station(int s, int t, vector<int> c)
{
    int i,j,n = c.size();
    if(s == 0)
    {
        for(i=0; i<n; i++)
        {
            if(t <= c[i])
            {
                return c[i];
            }
        }
        return c[n-1];
    }
    if(s < c[0])
    {
        for(i=0; i<n-1; i++)
        {
            if(t <= c[i])
            {
                return c[i];
            }
        }
        return c[n-1];
    }
    for(i=n-1; i>0; i--)
    {
        if(t >= c[i])
        {
            return c[i];
        }
    }
	return c[0];
}
//int main()
//{
//    cout << "Hello world!" << endl;
//    return 0;
//}

Compilation message

stations.cpp: In function 'int re(int, int, int)':
stations.cpp:17:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(i=0; i<pa[cn].size(); i++)
      |              ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:35:11: warning: unused variable 'j' [-Wunused-variable]
   35 |     int i,j,f,t;
      |           ^
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:58:11: warning: unused variable 'j' [-Wunused-variable]
   58 |     int i,j,n = c.size();
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 468 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1008
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 332 KB Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=1507
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 542 ms 776 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 953 ms 656 KB Output is correct
2 Correct 679 ms 784 KB Output is correct
3 Incorrect 609 ms 668 KB Wrong query response.
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 594 ms 768 KB Wrong query response.
2 Halted 0 ms 0 KB -