답안 #1060549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060549 2024-08-15T17:09:07 Z Mihailo 기지국 (IOI20_stations) C++17
0 / 100
3000 ms 2097152 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define pll pair<long long, long long>
#define MOD 1000000007
typedef long long ll;
using namespace std;
mt19937 mt(time(nullptr));
/*
static int max_label = 0;
static int r, n, k, q;
static std::vector<int> u, v, labels, answers;
static std::map<int, int> reverse_labels;
static std::vector<std::vector<int>> adjlist;
static int s, t, w;
static std::vector<int> c;
*/
vector<int> adj[2000];
bool d[2000];
ll mm, m[2000];

void mark(ll node) {
	m[node]=mm;
	mm++;
}

void dfsd(ll node, ll prev) {
	d[node]=!d[prev];
	for(auto cur:adj[node]) {
		if(cur!=prev) dfsd(cur, node);
	}
}

void euler(ll node, ll prev) {
	if(d[node]) mark(node);
	for(auto cur:adj[node]) {
		if(cur!=prev) euler(cur, node);
	}
	if(!d[node]) mark(node);
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	for(int i=0; i<n-1; i++) {
		adj[u[i]].pb(v[i]);
		adj[v[i]].pb(u[i]);
	}
	dfsd(0, 0);
	euler(0, 0);
	vector<int> rez;
	for(int i=0; i<n; i++) rez.pb(i);
	return rez;
}

int find_next_station(int s, int t, vector<int> c) {
	if(c[0]>s) {
		if(t<s||t>=c[c.size()-1]) {
			return c[c.size()-1];
		}
		for(int i=0; i<c.size(); i++) {
			if(t<=c[i]) return c[i];
		}
	}
	else {
		if(t>s||t<=c[0]) {
			return c[0];
		}
		for(int i=c.size()-1; i>=0; i--) {
			if(t>=c[i]) return c[i];
		}
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:61:17: 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:73:1: warning: control reaches end of non-void function [-Wreturn-type]
   73 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1405 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3066 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2901 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 575 ms 684 KB Output is correct
2 Runtime error 1304 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2702 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -