Submission #967493

# Submission time Handle Problem Language Result Execution time Memory
967493 2024-04-22T08:58:24 Z WendidIask0303 Stations (IOI20_stations) C++17
0 / 100
580 ms 936 KB
#include "stations.h"
#include <vector>

using namespace std;

vector<int> adj[1001];
vector<int> a;
bool vis[1001];
int timer = 0;

void dfs(int u, int t){
	if (t == 0){
        a[u] = timer;
        timer++;
    }
	vis[u] = true;
	for (auto v:adj[u]){
		if (vis[v]) continue;
		dfs(v, t);
	}
    if (t == 1){
        a[u] = timer;
        timer++;
    }
}

vector<int> label(int n, int k, vector<int> u, vector<int> v){
    timer = 0;
    a.clear();
    a.resize(n);
	for (int i=0; i<n; i++){
        adj[i].clear();
        vis[i] = false;
    }
	for (int i=0; i<n-1; i++){
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	dfs(0, 0);
	return a;
}
 
int find_next_station(int s, int t, vector<int> c){
	if (c[c.size()-1] < s){
		int ans = c[0];
		for (auto x:c){
			if (min(s, x) <= t && t <= max(s, x)) ans = x;
		}
        return ans;
	}
    else {
		for (auto x:c){
            if (min(s, x) <= t && t <= max(s, x)) return x;
        }
		return c[c.size()-1];
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 356 ms 888 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 280 ms 852 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 344 ms 892 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 580 ms 684 KB Output is correct
2 Correct 408 ms 936 KB Output is correct
3 Incorrect 370 ms 684 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 339 ms 888 KB Wrong query response.
2 Halted 0 ms 0 KB -