Submission #430445

# Submission time Handle Problem Language Result Execution time Memory
430445 2021-06-16T13:54:01 Z alishahali1382 Stations (IOI20_stations) C++14
0 / 100
1073 ms 568 KB
#include "stations.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<"{"<<#x<<", "<<#y<<"}={"<<x<<", "<<y<<"}\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debugv(abcd) {cerr<<#abcd<<": "; for (auto dcba:abcd) cerr<<dcba<<", ";cerr<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())

const int inf=1000000100; // 1e9
const ll INF=10000000001000000; // 1e16
const int mod=1000000007;
const int MAXN=1010;

int n, m, k, x, y, a, b, t, ans;
int stt[MAXN], fnt[MAXN], timer;
vi G[MAXN];

void dfs(int node, int par){
	stt[node]=timer++;
	for (int v:G[node]) if (v!=par) dfs(v, node);
	fnt[node]=timer;
}

vi label(int _n, int _k, vi U, vi V){
	n=_n;
	k=_k;
	vi out(n);
	for (int i=0; i<n; i++) G[i].clear();
	for (int i=0; i<n-1; i++){
		int u=U[i], v=V[i];
		G[u].pb(v);
		G[v].pb(u);
	}
	timer=0;
	dfs(0, 0);
	for (int i=0; i<n; i++) out[i]=stt[i]*1000+fnt[i]-1;
	return out;
}

int find_next_station(int s, int t, vi adj){
	sort(all(adj));
	for (int x:adj) if (x==t) return x;
	int stt_s=(s-1)/1000, fnt_s=(s-1)%1000+1;
	int stt_t=(t-1)/1000, fnt_t=(t-1)%1000+1;
	if (stt_t<stt_s || fnt_s<=stt_t) return adj[0];
	for (int i=1; i<SZ(adj); i++){
		int v=adj[i];
		int stt_v=(v-1)/1000, fnt_v=(v-1)%1000+1;
		if (stt_v<=stt_t && stt_t<fnt_v) return v;
	}
	return -1;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, vi)':
stations.cpp:53:24: warning: unused variable 'fnt_t' [-Wunused-variable]
   53 |  int stt_t=(t-1)/1000, fnt_t=(t-1)%1000+1;
      |                        ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 320 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 308 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 537 ms 516 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 923 ms 568 KB Output is correct
2 Correct 1073 ms 400 KB Output is correct
3 Incorrect 948 ms 400 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 833 ms 508 KB Wrong query response.
2 Halted 0 ms 0 KB -