답안 #432217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432217 2021-06-18T03:40:33 Z Amylopectin 기지국 (IOI20_stations) C++14
0 / 100
3000 ms 2097156 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;
	vector<int> lab(n);
	for(i=0; i<n-1; i++)
	{
        pa[u[i]].push_back(v[i]);
        pa[v[i]].push_back(u[i]);
	}
	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];
            }
        }
    }
    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;
      |           ^
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:11: warning: unused variable 'j' [-Wunused-variable]
   52 |     int i,j,n = c.size();
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2257 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3047 ms 452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1404 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 880 ms 656 KB Output is correct
2 Runtime error 1068 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2334 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -