Submission #1080201

# Submission time Handle Problem Language Result Execution time Memory
1080201 2024-08-29T07:58:47 Z Ghulam_Junaid Stations (IOI20_stations) C++17
5 / 100
634 ms 1028 KB
// REAL
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;

vector<int> label(int n, int k, vector<int> u, vector<int> v){
    vector<int> ans(n), g[n];
    for (int i = 0; i < n - 1; i ++){
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }
    int l = 0;
    for (int i = 0; i < n; i ++)
        if (g[i].size() == 1)
            l = i;

    int cur = 0, p = -1;
    for (int i = l; 1; ){
        ans[i] = cur;
        cur++;

        if (g[i].size() == 1){
            if (g[i][0] == p) break;
            p = i;
            i = g[i][0];
        }
        else{
            if (g[i][0] == p){
                p = i;
                i = g[i][1];
            }
            else{
                p = i;
                i = g[i][0];
            }
        }
    }
    return ans;
}

int find_next_station(int s, int t, vector<int> c){
    for (int x : c){
        if (x < s and t < s) return x;
        if (x > s and t > s) return x; 
    }
}

/*int main(){
    int t;
    cin >> t;
    while (t--){
        int n, k;
        cin >> n >> k;
        vector<int> u(n - 1), v(n - 1);

        for (int i = 0; i < n - 1; i ++)
            cin >> u[i] >> v[i];
        label(n, k, u, v);
        for (int i = 0; i < n; i ++){
            cout << i << " :: " << val[i] << endl;
        }

        // for (int i = 0; i < n; i ++){
        //     for (int j = 0; j < n; j ++){
        //         if (i == j) continue;

        //         vector<int> adj;
        //         for (int x : g[i])
        //             adj.push_back(val[x]);
        //         sort(adj.begin(), adj.end());

        //         int res = find_next_station(val[i], val[j], adj);
        //         cout << val[i] << " -- " << val[j] << " == " << res << endl;
        //     }
        // }
    }
}*/

/*

1
23 23
1 0
1 2
1 3
0 4
0 5
0 6
2 7
3 8
3 9
4 10
4 11
5 12
6 13 
7 14 
7 15
8 16
9 17
9 18
9 19
14 20
14 21
14 22

*/

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 354 ms 936 KB Output is correct
2 Correct 320 ms 684 KB Output is correct
3 Correct 584 ms 684 KB Output is correct
4 Correct 444 ms 684 KB Output is correct
5 Correct 413 ms 688 KB Output is correct
6 Correct 290 ms 684 KB Output is correct
7 Correct 318 ms 684 KB Output is correct
8 Correct 2 ms 1020 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 358 ms 684 KB Output is correct
2 Correct 286 ms 684 KB Output is correct
3 Correct 634 ms 688 KB Output is correct
4 Correct 463 ms 684 KB Output is correct
5 Correct 428 ms 684 KB Output is correct
6 Correct 324 ms 684 KB Output is correct
7 Correct 297 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
11 Incorrect 0 ms 344 KB Invalid labels (duplicates values). scenario=1, label=0
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 583 ms 684 KB Output is correct
2 Correct 439 ms 684 KB Output is correct
3 Correct 433 ms 684 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Incorrect 1 ms 344 KB Invalid labels (duplicates values). scenario=0, label=0
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 388 ms 684 KB Output is correct
2 Correct 349 ms 684 KB Output is correct
3 Correct 601 ms 684 KB Output is correct
4 Correct 434 ms 684 KB Output is correct
5 Correct 424 ms 684 KB Output is correct
6 Correct 276 ms 684 KB Output is correct
7 Correct 301 ms 684 KB Output is correct
8 Correct 2 ms 1028 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Incorrect 3 ms 344 KB Invalid labels (duplicates values). scenario=0, label=0
12 Halted 0 ms 0 KB -