Submission #312402

# Submission time Handle Problem Language Result Execution time Memory
312402 2020-10-13T06:10:07 Z jainbot27 Stations (IOI20_stations) C++17
8 / 100
977 ms 1040 KB
#include <bits/stdc++.h>
// #include "stations.h"
using namespace std;

#define f first
#define s second
#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int)x.size()

#define FOR(x, y, z) for(int x = (y); x < (z); x++)
#define ROF(x, z, y) for(int x = (y-1); x >= (z); x--)
#define F0R(x, z) FOR(x, 0, z)
#define R0F(x, z) ROF(x, 0, z)
#define trav(x, y) for(auto&x:y)

using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

template<class T> inline bool ckmin(T&a, T b) {return b < a ? a = b, 1 : 0;}
template<class T> inline bool ckmax(T&a, T b) {return b > a ? a = b, 1 : 0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const char nl = '\n';
const int mxN = 1001;
const int MOD = 1e9 + 7;
const long long infLL = 1e18;

vi sol, adj[mxN]; bool vis[mxN]; int num = 0;

void dfs(int u, bool b){
    vis[u] = 1;
    if(!b) sol[u] = num++;
    trav(v, adj[u]) if(!vis[v]) dfs(v, b^1);
    if(b) sol[u] = num++;
}
vi label(int n, int k, vi x, vi y){
    F0R(i, n) vis[i] = 0, num= 0, sol.clear();
    sol.resize(n);
    F0R(i, n-1){
        adj[x[i]].pb(y[i]);
        adj[y[i]].pb(x[i]);
    }
    dfs(0, 0);
    return sol;
}
int find_next_station(int s, int t, vi sz){
    int x = sz[0] , y = sz.back(); 
    if(s < x ) {
        if(t < s || t > y ) return y;
        F0R(i, siz(sz)) if(sz[i] >= t) return sz[i];
    }
    if(t > s || t < x ) return x;
    R0F(i, siz(sz)) if(sz[i] <= t) return sz[i];
}

// int main(){
//     int n, k; cin >> n >> k;
//     vi U, V;
//     F0R(i, n-1){
//         int uu, vv; cin >> uu;
//         U.pb(uu);
//     }
//     F0R(i, n-1){
//         int uu, vv; cin >> vv;
//         V.pb(vv);
//     }

//     vi ANS = label(n, k, U, V);
//     F0R(i, n){
//         cout << ANS[i] << "\n";
//     }
// }

Compilation message

stations.cpp: In function 'int find_next_station(int, int, vi)':
stations.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 605 ms 1024 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 519 ms 1024 KB Output is correct
2 Correct 562 ms 800 KB Output is correct
3 Correct 909 ms 776 KB Output is correct
4 Correct 713 ms 872 KB Output is correct
5 Correct 682 ms 1040 KB Output is correct
6 Correct 530 ms 952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 535 ms 1024 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 977 ms 876 KB Output is correct
2 Incorrect 633 ms 876 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 543 ms 1032 KB Wrong query response.
2 Halted 0 ms 0 KB -