Submission #313214

# Submission time Handle Problem Language Result Execution time Memory
313214 2020-10-15T14:09:51 Z NhatMinh0208 Stations (IOI20_stations) C++14
0 / 100
1110 ms 5584 KB
/*
khoi orz, go check out his algo
-normie-
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FILE_IN "ninja.inp"
#define FILE_OUT "ninja.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 1048576
#define fi first
#define se second
#define pow2(x) (ll(1)<<x)
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define For(i,__,___) for(int i=__;i<=___;i++)
#define Rep(i,__,___) for(int i=__;i>=___;i--)
#define ordered_set tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update>
#define endl "\n"
#define bi BigInt
#define ll long long
#define pi 3.1415926535897
//------START-----------//
vector<int> gt[100001];
int used[100001],label_result[100001],t;
//------END-----------//
void dfs1(int x, int parity)
{
  used[x]=1;
  if (parity==0)
  {
    label_result[x]=t;
    t++;
  }
  for (int g : gt[x]) if (!used[g])
  {
    dfs1(g,1-parity);
  }
  if (parity==1)
  {
    label_result[x]=t;
    t++;
  }
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
  for (int i=0;i<n-1;i++)
  {
    gt[u[i]].push_back(v[i]);
    gt[v[i]].push_back(u[i]);
  }
  dfs1(0,0);
  vector<int> res;
  for (int i=0;i<n;i++)
  {
    res.push_back(label_result[i]);
  }
  return res;
}
int find_next_station(int s, int t, vector<int> c)
{
  sort(c.begin(),c.end());
  if (c.size()==1) return c[0];
  else if (s==0)
  {
    for (int i=c.size()-1;i>=0;i--) if (t<=c[i]) return c[i];
  }
  else if (s<c[0])
  {
    if ((t<s)or(t>c[c.size()-2])) return c[c.size()-1];
    else for (int i =c.size()-2;i>=0;i--) if (t<=c[i]) return c[i];
  }
  else
  {
    if ((t>s)or(t<c[1])) return c[0];
    else for (int i =1;i<c.size();i++) if (t>=c[i]) return c[i];
  }
}

Compilation message

stations.cpp:8: warning: ignoring #pragma comment  [-Wunknown-pragmas]
    8 | #pragma comment(linker, "/stack:200000000")
      | 
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:89:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |     else for (int i =1;i<c.size();i++) if (t>=c[i]) return c[i];
      |                        ~^~~~~~~~~
stations.cpp:91:1: warning: control reaches end of non-void function [-Wreturn-type]
   91 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2816 KB Invalid labels (duplicates values). scenario=2, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2816 KB Invalid labels (duplicates values). scenario=3, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2808 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1110 ms 5580 KB Output is correct
2 Incorrect 759 ms 5584 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2816 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -