Submission #544346

# Submission time Handle Problem Language Result Execution time Memory
544346 2022-04-01T18:53:28 Z Lobo Stations (IOI20_stations) C++17
0 / 100
1 ms 464 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
// #define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = 1100;

int find_next_station(int s, int t, vector<int> c) {
    // cout << "  " << s << " " << t << endl;
    for(auto x : c) {
        if(t == x) return x;
    }

    if(s == 0) {
        for(int i = 0; i < c.size(); i++) {
            if(t < c[i]) return c[i];
        }
    }

    if(s < c[0]) {
        //s é in
        if(t < s) return c.back();
        if(t > c.back()) return c.back();
        for(int i = 0; i < c.size(); i++) {
            if(t < c[i]) return c[i];
        }
    }
    else {
        if(t > s) return c[0];
        if(t > c[0]) return c[0];
        for(int i = 1; i < c.size(); i++) {
            if(t > c[i]) return c[i];
        }
    }
    return -1;
}

vector<int> lab;
int timer = 0;
vector<int> g[maxn];

void dfs(int a, int col, int ant) {
    if(col == 0) {
        lab[a] = timer;
        timer++;
    }
    
    for(auto b : g[a]) {
        if(b == ant) continue;

        dfs(b,col^1,a);
    }

    if(col == 1) {
        lab[a] = timer;
        timer++;
    }

}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    assert(1 == 0);
    lab.resize(n);
    for(int i = 0; i < n; i++) {
        g[u[i]].pb(v[i]);
        g[v[i]].pb(u[i]);
    }
    dfs(0,0,0);
    return lab;
}

// int32_t main() {
//     ios::sync_with_stdio(false); cin.tie(0);

//     freopen("in.in", "r", stdin);
//     // freopen("out.out", "w", stdout);

//     int n, k; cin >> n >> k;
//     vector<int> u,v;
//     for(int i = 0; i < n-1; i++) {
//         int a,b; cin >> a >> b;
//         u.pb(a);
//         v.pb(b);
//     }
//     label(n,k,u,v);

//     int q; cin >> q;
//     while(q--) {
//         int s, t, ans;
//         cin >> s >> t >> ans;
//         vector<int> v;
//         for(auto b : g[s]) {
//             v.pb(lab[b]);
//         }
//         sort(all(v));
//         cout << " " << lab[ans] << endl << "  =" << find_next_station(lab[s],lab[t],v) << endl;
//     }

    

// }

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int i = 0; i < c.size(); i++) {
      |                        ~~^~~~~~~~~~
stations.cpp:34:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i = 0; i < c.size(); i++) {
      |                        ~~^~~~~~~~~~
stations.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int i = 1; i < c.size(); i++) {
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -