답안 #1068404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068404 2024-08-21T09:43:25 Z mc061 통행료 (IOI18_highway) C++17
5 / 100
11 ms 1128 KB
#include <bits/stdc++.h>
using namespace std;

int m;
long long a, b;

long long ask(const std::vector<int> &w);
long long get(const vector<int>& busy) {
    vector<int> q(m, 0);
    for (int i : busy) q[i] = 1;
    return ask(q);
}
void answer(int s, int t);

void rec(vector<int> now, vector<vector<int>>& full, int path_le) {
    if (!now.size()) return;
    long long here = get(now);
    if (here == 1ll*path_le*a) return;
    if (here == 1ll*now.size()*b + 1ll*(path_le-now.size())*a) {
        full.push_back(now);
        return;
    }
    random_shuffle(now.begin(), now.end());
    vector<int> left, right;
    for (int i = 0; i < now.size()/2; ++i) {
        left.push_back(now[i]);
    }
    for (int i = now.size()/2; i < now.size(); ++i) {
        right.push_back(now[i]);
    }
    rec(left, full, path_le);
    rec(right, full, path_le);
}

void find_pair(int N, std::vector<int> U, std::vector<int> V, int A_, int B_) {
    a = A_;
    b = B_;
    m = U.size();
    vector<int> v(U.size());
    iota(v.begin(), v.end(), 0);
    vector<vector<int>> full;
    long long path_le = get(v) / b;
    rec(v, full, path_le);
    map<int, int> c;
    for (auto& x : full) {
        for (int j : x) {
            c[U[j]]++;
            c[V[j]]++;
        }
    }
    vector<int> vs;
    for (auto [x, y] : c) {
        if (y == 1) vs.push_back(x);
    }
    answer(vs[0], vs[1]);
}

Compilation message

highway.cpp: In function 'void rec(std::vector<int>, std::vector<std::vector<int> >&, int)':
highway.cpp:19:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   19 |     if (here == 1ll*now.size()*b + 1ll*(path_le-now.size())*a) {
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
highway.cpp:25:23: 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 < now.size()/2; ++i) {
      |                     ~~^~~~~~~~~~~~~~
highway.cpp:28:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = now.size()/2; i < now.size(); ++i) {
      |                                ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 760 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 856 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 1128 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -