답안 #412203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
412203 2021-05-26T15:38:14 Z Carmel_Ab1 자매 도시 (APIO20_swap) C++17
17 / 100
2000 ms 45924 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

umap<int,umap<int,int>>c;
vvi 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]);
        g[V[i]].pb(U[i]);
        c[U[i]][V[i]]=c[V[i]][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(c[i][g[i][j]]<=w)
                gt[i].pb(g[i][j]);
    vi prv(n,-1),deg(n);
    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:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         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 12 ms 496 KB Output is correct
5 Correct 22 ms 712 KB Output is correct
6 Correct 25 ms 720 KB Output is correct
7 Correct 28 ms 716 KB Output is correct
8 Correct 28 ms 688 KB Output is correct
9 Execution timed out 2061 ms 38476 KB Time limit exceeded
10 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 2073 ms 45924 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 12 ms 496 KB Output is correct
5 Correct 22 ms 712 KB Output is correct
6 Correct 25 ms 720 KB Output is correct
7 Correct 28 ms 716 KB Output is correct
8 Correct 28 ms 688 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 23 ms 588 KB Output is correct
11 Correct 28 ms 732 KB Output is correct
12 Correct 28 ms 708 KB Output is correct
13 Correct 23 ms 560 KB Output is correct
14 Correct 25 ms 644 KB Output is correct
15 Correct 27 ms 716 KB Output is correct
16 Correct 29 ms 728 KB Output is correct
17 Correct 28 ms 736 KB Output is correct
18 Correct 30 ms 588 KB Output is correct
19 Correct 20 ms 564 KB Output is correct
20 Correct 28 ms 748 KB Output is correct
21 Correct 28 ms 696 KB Output is correct
22 Correct 23 ms 588 KB Output is correct
23 Correct 22 ms 616 KB Output is correct
24 Correct 38 ms 716 KB Output is correct
25 Correct 40 ms 716 KB Output is correct
26 Correct 45 ms 844 KB Output is correct
27 Correct 25 ms 760 KB Output is correct
28 Correct 41 ms 716 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 12 ms 496 KB Output is correct
6 Correct 22 ms 712 KB Output is correct
7 Correct 25 ms 720 KB Output is correct
8 Correct 28 ms 716 KB Output is correct
9 Correct 28 ms 688 KB Output is correct
10 Execution timed out 2061 ms 38476 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 12 ms 496 KB Output is correct
5 Correct 22 ms 712 KB Output is correct
6 Correct 25 ms 720 KB Output is correct
7 Correct 28 ms 716 KB Output is correct
8 Correct 28 ms 688 KB Output is correct
9 Execution timed out 2061 ms 38476 KB Time limit exceeded
10 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 12 ms 496 KB Output is correct
6 Correct 22 ms 712 KB Output is correct
7 Correct 25 ms 720 KB Output is correct
8 Correct 28 ms 716 KB Output is correct
9 Correct 28 ms 688 KB Output is correct
10 Execution timed out 2061 ms 38476 KB Time limit exceeded
11 Halted 0 ms 0 KB -