답안 #984583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984583 2024-05-16T19:56:54 Z Mr_Ph 자매 도시 (APIO20_swap) C++17
37 / 100
2000 ms 23720 KB
#include "swap.h"

#include <bits/stdc++.h>
// #include "grader.cpp"
using namespace std;
vector<vector<pair<int,int>>>adj;
int mx=0,n=0;
void init(int N, int m,std::vector<int> u, std::vector<int> v, std::vector<int> w) {
    adj.resize(N+1);
    for(int i=0;i<m;i++)
    {
        adj[u[i]].push_back({v[i],w[i]});
        adj[v[i]].push_back({u[i],w[i]});
        mx=max(mx,w[i]);
    }
    n=N;
}
vector<vector<int>>newadj;
vector<int>vs;
bool check(int node,int parent)
{
    // cout<<node<<" "<<parent<<endl;
    int cnt=0;
    if(vs[node]==true)return 1;
    vs[node]=true;
    for(auto i:newadj[node])
    {
        if(i==parent)continue;
        cnt++;
    }
    if(cnt>1&&parent!=-1)return 1;
    else
    {
        int lol=0;
        for(auto i:newadj[node])
        {
            if(i==parent)continue;
            lol|=check(i,node);
        }
        return lol;
    }
}
bool findy(int node,int y)
{
    vs[node]=true;
    if(node==y)return 1;
    int lol=0;
    for(auto i:newadj[node])
    {
        if(!vs[i])
            lol|=findy(i,y);
    }
    return lol;
}
int getMinimumFuelCapacity(int x, int y) {
    int l=1,r=mx;
    int ans=-1;
    newadj.resize(n+1);
    vs.resize(n+1);
    for(int i=0;i<=n;i++)vs[i]=0;
    while(l<=r){
        int mid=(l+r)/2;
        for(int i=0;i<n;i++)
            for(auto j:adj[i])
                if(j.second<=mid)
                    newadj[i].push_back(j.first);
        int node=-1;
        // cout<<"HI"<<endl;
        int e=check(x,-1);
        for(int i=0;i<n;i++)vs[i]=0;
        int ee=findy(x,y);
        if(e&&ee)
        {
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
        for(int i=0;i<n;i++)
        {
            vs[i]=0;
            newadj[i].clear();
        }
    }
    return ans;
}

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:67:13: warning: unused variable 'node' [-Wunused-variable]
   67 |         int node=-1;
      |             ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 576 KB Output is correct
9 Correct 199 ms 14016 KB Output is correct
10 Correct 392 ms 18336 KB Output is correct
11 Correct 549 ms 18680 KB Output is correct
12 Correct 863 ms 19004 KB Output is correct
13 Correct 1100 ms 19752 KB Output is correct
14 Execution timed out 2008 ms 15856 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Execution timed out 2059 ms 15608 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 576 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 556 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 3 ms 604 KB Output is correct
25 Correct 3 ms 604 KB Output is correct
26 Correct 5 ms 600 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 4 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 500 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 576 KB Output is correct
10 Correct 199 ms 14016 KB Output is correct
11 Correct 392 ms 18336 KB Output is correct
12 Correct 549 ms 18680 KB Output is correct
13 Correct 863 ms 19004 KB Output is correct
14 Correct 1100 ms 19752 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 556 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 3 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 5 ms 600 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 4 ms 444 KB Output is correct
34 Correct 18 ms 2396 KB Output is correct
35 Correct 225 ms 17700 KB Output is correct
36 Correct 207 ms 16828 KB Output is correct
37 Correct 202 ms 15288 KB Output is correct
38 Correct 325 ms 14792 KB Output is correct
39 Correct 247 ms 14660 KB Output is correct
40 Correct 272 ms 13616 KB Output is correct
41 Correct 681 ms 17440 KB Output is correct
42 Correct 293 ms 16804 KB Output is correct
43 Correct 365 ms 16824 KB Output is correct
44 Correct 496 ms 15812 KB Output is correct
45 Correct 811 ms 17864 KB Output is correct
46 Correct 310 ms 17200 KB Output is correct
47 Correct 362 ms 15000 KB Output is correct
48 Correct 427 ms 15416 KB Output is correct
49 Correct 90 ms 11604 KB Output is correct
50 Correct 122 ms 8896 KB Output is correct
51 Correct 595 ms 15204 KB Output is correct
52 Correct 814 ms 21388 KB Output is correct
53 Correct 836 ms 21152 KB Output is correct
54 Correct 1587 ms 23720 KB Output is correct
55 Correct 337 ms 18336 KB Output is correct
56 Correct 1029 ms 21356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 500 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 576 KB Output is correct
9 Correct 199 ms 14016 KB Output is correct
10 Correct 392 ms 18336 KB Output is correct
11 Correct 549 ms 18680 KB Output is correct
12 Correct 863 ms 19004 KB Output is correct
13 Correct 1100 ms 19752 KB Output is correct
14 Execution timed out 2008 ms 15856 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 500 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 4 ms 576 KB Output is correct
10 Correct 199 ms 14016 KB Output is correct
11 Correct 392 ms 18336 KB Output is correct
12 Correct 549 ms 18680 KB Output is correct
13 Correct 863 ms 19004 KB Output is correct
14 Correct 1100 ms 19752 KB Output is correct
15 Execution timed out 2008 ms 15856 KB Time limit exceeded
16 Halted 0 ms 0 KB -