Submission #1158644

#TimeUsernameProblemLanguageResultExecution timeMemory
1158644modwweStations (IOI20_stations)C++20
100 / 100
308 ms824 KiB
#include "stations.h"
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int   long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "ftree"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l,int r)
{
    return uniform_int_distribution<int>(l,r)(rd);
}
void phongbeo();
const int inf = 1e9;
const ll mod2 = 1e9+7;
//const ll base=67;
int  n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,lim,w,l,r,dem5,dem6,dem7,dem9;
int kk;
int t;
int el = 19;/*
main()
{
    if(fopen(task2".inp","r"))
    {
        fin(task2);
        fou(task2);
    }
    if(fopen(task".inp","r"))
    {
        // fin(task);
        fou(task);
    }
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
//   cin>>s1;
    // int t;cin>>t;while(t--)
    phongbeo(),down
    checktime
}*/
vector<int> v[10001];
int in[10001],ou[10001],depth[10001];
void dfs(int x,int y)
{
    if(depth[x]%2==0)
    in[x]=++dem;
    for(auto f:v[x])
        if(f^y)
            depth[f]=1-depth[x],dfs(f,x);
    if(depth[x]%2==1)
    ou[x]=++dem;
}
vector<int> label(int n,int k,vector<int>U,vector<int> V)
{
    for(int i=0;i<n;i++)
        v[i].clear(),depth[i]=0;
    for(int i=0; i<n-1; i++)
        v[U[i]].pb(V[i]),
        v[V[i]].pb(U[i]);
    dem=-1;
    dfs(0,0);
    vector<int> send;
    for(int i=0; i<n; i++)
        if(depth[i])send.pb(ou[i]);
        else send.pb(in[i]);
    return send;
}
int find_next_station(int x,int y,vector<int> c)
{
    if(c.size()==1) return c[0];
    if(c[0]>x)
    {
        int a,b;
        a=x;
        for(int i=0; i<c.size()-1; i++)
        {
            b=c[i];
            if(a<=y&&y<=b)return b;
            a=b+1;
        }
        return c.back();
    }
    else
    {
        int a,b;
        b=x;
     for(int i=c.size()-1;i>=1;--i)
     {
        a=c[i];
        if(a<=y&&y<=b)return a;
        b=a-1;
     }
     return c[0];
    }
}
/*
void phongbeo()
{
 vector<int> haha= label(5,100,{0,1,1,2},{1,2,3,4});
for(auto x:haha)
    cout<<x<<" ";
 down
   cout<<find_next_station(4,2,{0,1,3});
}*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...