제출 #293174

#제출 시각아이디문제언어결과실행 시간메모리
293174egekabas통행료 (IOI18_highway)C++14
51 / 100
291 ms15760 KiB
#include "highway.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<ll, ll> pii;
typedef pair<ld, ld> pld;
vector<int> w;
vector<pii> g[100000];
int vis[100000];
vector<pii> vec[2];

ll begval;
int get(vector<pii> &vec){
    int l = 0, r = vec.size()-1;
    while(l < r){
        int m = (l+r)/2;
        for(int i = m+1; i <= r; ++i)
            w[vec[i].ss] = 1;
        if(ask(w) == begval)
            r = m;
        else
            l = m+1;
        for(int i = m+1; i <= r; ++i)
            w[vec[i].ss] = 0;
    }
    return vec[l].ff;
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
    w.resize(U.size());
    for(int i = 0; i < U.size(); ++i){
        g[U[i]].pb({V[i], i});
        g[V[i]].pb({U[i], i});
    }
    begval = ask(w);
    int l = 0, r = U.size()-1;
    while(l < r){
        int m = (l+r)/2;
        for(int i = l; i <= m; ++i)
            w[i] = 1;
        if(ask(w) != begval)
            r = m;
        else
            l = m+1;
        for(int i = l; i <= m; ++i)
            w[i] = 0;
    }
    int e = l;
    queue<pair<int, pii>> q;
    q.push({0, {U[e], e}});
    q.push({1, {V[e], e}});
    vis[U[e]] = vis[V[e]] = 1;
    while(q.size()){
        int type = q.front().ff;
        int v = q.front().ss.ff;
        int come = q.front().ss.ss;
        q.pop();
        vec[type].pb({v, come});
        for(auto u : g[v])
            if(vis[u.ff] == 0){
                vis[u.ff] = 1;
                q.push({type, u});
            }
    }
    answer(get(vec[0]), get(vec[1]));
}   

컴파일 시 표준 에러 (stderr) 메시지

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i = 0; i < U.size(); ++i){
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...