답안 #1067260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067260 2024-08-20T13:35:10 Z Ignut Simurgh (IOI17_simurgh) C++17
0 / 100
1 ms 348 KB
// Ignut

#include "simurgh.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 555;

vector<int> g[N];

vector<int> MakeVector(vector<int> &vec, int l, int r) {
    vector<int> res;
    for (int i = l; i <= r; i ++) res.push_back(vec[i]);
    return res;
}

bool ans[N * N];

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
    for (int i = 0; i < u.size(); i ++) {
        g[u[i]].push_back(i);
        g[v[i]].push_back(i);
    }
    for (int v = 0; v < n; v ++) {
        int sz = g[v].size();
        int total = count_common_roads(MakeVector(g[v], 0, sz - 1));
        int l = -1;
        for (int j = 0; j < total; j ++) {
            int lo = l + 1, hi = sz - 1;
            // int prev_cnt = count_common_roads(MakeVector(g[v], l + 1, sz - 1));
            while (lo < hi) {
                int mid = lo + (hi - lo) / 2;
                int cnt = count_common_roads(MakeVector(g[v], l + 1, mid));
                if (cnt >= 1)
                    hi = mid;
                else
                    lo = mid + 1;
            }
            ans[g[v][lo]] = true;
            l = lo;
        }
    }
    vector<int> res;
    for (int i = 0; i < u.size(); i ++) if (ans[i]) res.push_back(i);
    return res;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < u.size(); i ++) {
      |                     ~~^~~~~~~~~~
simurgh.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i = 0; i < u.size(); i ++) if (ans[i]) res.push_back(i);
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB correct
2 Incorrect 0 ms 348 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -