답안 #1080234

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080234 2024-08-29T08:12:34 Z Ghulam_Junaid 기지국 (IOI20_stations) C++17
5 / 100
638 ms 776 KB
#include <bits/stdc++.h>
// #include "stations.h"
using namespace std;

vector<int> ans, g[1000];

vector<int> label(int n, int k, vector<int> u, vector<int> v){
    ans.resize(n);
    for (int i = 0; i < n; i ++) g[i].clear();
        
    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 ++){
//             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;
//             }
//         }
//     }
// }

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
   49 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 331 ms 684 KB Output is correct
2 Correct 294 ms 684 KB Output is correct
3 Correct 594 ms 684 KB Output is correct
4 Correct 384 ms 684 KB Output is correct
5 Correct 384 ms 684 KB Output is correct
6 Correct 335 ms 684 KB Output is correct
7 Correct 306 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 772 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 362 ms 684 KB Output is correct
2 Correct 295 ms 684 KB Output is correct
3 Correct 557 ms 684 KB Output is correct
4 Correct 478 ms 684 KB Output is correct
5 Correct 380 ms 684 KB Output is correct
6 Correct 338 ms 688 KB Output is correct
7 Correct 297 ms 684 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Incorrect 1 ms 340 KB Invalid labels (duplicates values). scenario=2, label=2
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 638 ms 684 KB Output is correct
2 Correct 444 ms 684 KB Output is correct
3 Correct 460 ms 684 KB Output is correct
4 Correct 2 ms 772 KB Output is correct
5 Correct 2 ms 776 KB Output is correct
6 Correct 0 ms 776 KB Output is correct
7 Incorrect 0 ms 456 KB Invalid labels (duplicates values). scenario=0, label=0
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 341 ms 688 KB Output is correct
2 Correct 310 ms 688 KB Output is correct
3 Correct 604 ms 684 KB Output is correct
4 Correct 489 ms 684 KB Output is correct
5 Correct 380 ms 680 KB Output is correct
6 Correct 277 ms 684 KB Output is correct
7 Correct 308 ms 684 KB Output is correct
8 Correct 2 ms 776 KB Output is correct
9 Correct 3 ms 776 KB Output is correct
10 Correct 1 ms 772 KB Output is correct
11 Incorrect 2 ms 460 KB Invalid labels (duplicates values). scenario=0, label=0
12 Halted 0 ms 0 KB -