답안 #412212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
412212 2021-05-26T15:41:15 Z Carmel_Ab1 자매 도시 (APIO20_swap) C++17
17 / 100
2000 ms 20620 KB
#include<bits/stdc++.h>
#include "swap.h"

//#include "grader.cpp"

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<ll>vl;
typedef vector<vl> vvl;
typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<ld> vld;
typedef pair<ld,ld> pld;
//typedef tree<ll, null_type, less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<typename T> ostream& operator<<(ostream& os, vector<T>& a){os<<"[";for(int i=0; i<ll(a.size()); i++){os << a[i] << ((i!=ll(a.size()-1)?" ":""));}os << "]\n"; return os;}

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define GLHF ios_base::sync_with_stdio(false); cin.tie(NULL)
#define print(x){for(auto ait:x) cout << ait << " "; cout << "\n";}
#define pb push_back
#define umap unordered_map


vector<vector<pi>> g;
void init(int n, int M,vi U,vi V,vi W){
    g.resize(n);
    for(int i=0; i<M; i++){
        g[U[i]].pb({V[i],W[i]});
        g[V[i]].pb({U[i],W[i]});
    }
}

bool ans;
void dfs(vvi &g,vector<bool>& vis,int src,int par){
    vis[src]=1;
    for(int nbr:g[src]) {
        if(nbr==par)continue;
        if(vis[nbr])ans=1;
        else dfs(g,vis,nbr,src);
        if(g[src].size()>2)ans=1;
    }
}
bool ok(int x,int y,int w){
    int n=g.size();
    vvi gt(n);
    for(int i=0; i<n; i++)
        for(int j=0; j<g[i].size(); j++)
            if(g[i][j].second<=w)
                gt[i].pb(g[i][j].first);
    vector<bool>vis(n);
    ans=0;
    dfs(gt,vis,x,-1);
    if(!vis[y])return 0;
    return ans;

}

int getMinimumFuelCapacity(int X, int Y){
    ll l=1,r=1e9,ans=-1;
    while(l<=r){
        ll m=(l+r)/2;
        if(ok(X,Y,m))
            ans=m,r=m-1;
        else
            l=m+1;
    }
    return ans;
}

Compilation message

swap.cpp: In function 'bool ok(int, int, int)':
swap.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for(int j=0; j<g[i].size(); j++)
      |                      ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 9 ms 360 KB Output is correct
5 Correct 14 ms 460 KB Output is correct
6 Correct 17 ms 460 KB Output is correct
7 Correct 19 ms 476 KB Output is correct
8 Correct 20 ms 480 KB Output is correct
9 Correct 850 ms 15872 KB Output is correct
10 Execution timed out 2067 ms 20620 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Execution timed out 2058 ms 15312 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 9 ms 360 KB Output is correct
5 Correct 14 ms 460 KB Output is correct
6 Correct 17 ms 460 KB Output is correct
7 Correct 19 ms 476 KB Output is correct
8 Correct 20 ms 480 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 16 ms 332 KB Output is correct
11 Correct 20 ms 440 KB Output is correct
12 Correct 19 ms 332 KB Output is correct
13 Correct 17 ms 396 KB Output is correct
14 Correct 17 ms 332 KB Output is correct
15 Correct 19 ms 424 KB Output is correct
16 Correct 20 ms 332 KB Output is correct
17 Correct 21 ms 556 KB Output is correct
18 Correct 20 ms 420 KB Output is correct
19 Correct 13 ms 404 KB Output is correct
20 Correct 19 ms 460 KB Output is correct
21 Correct 19 ms 412 KB Output is correct
22 Correct 9 ms 408 KB Output is correct
23 Correct 16 ms 332 KB Output is correct
24 Correct 23 ms 460 KB Output is correct
25 Correct 24 ms 460 KB Output is correct
26 Correct 27 ms 496 KB Output is correct
27 Correct 16 ms 472 KB Output is correct
28 Correct 23 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 9 ms 360 KB Output is correct
6 Correct 14 ms 460 KB Output is correct
7 Correct 17 ms 460 KB Output is correct
8 Correct 19 ms 476 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 850 ms 15872 KB Output is correct
11 Execution timed out 2067 ms 20620 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 9 ms 360 KB Output is correct
5 Correct 14 ms 460 KB Output is correct
6 Correct 17 ms 460 KB Output is correct
7 Correct 19 ms 476 KB Output is correct
8 Correct 20 ms 480 KB Output is correct
9 Correct 850 ms 15872 KB Output is correct
10 Execution timed out 2067 ms 20620 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 9 ms 360 KB Output is correct
6 Correct 14 ms 460 KB Output is correct
7 Correct 17 ms 460 KB Output is correct
8 Correct 19 ms 476 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 850 ms 15872 KB Output is correct
11 Execution timed out 2067 ms 20620 KB Time limit exceeded
12 Halted 0 ms 0 KB -