Submission #409868

# Submission time Handle Problem Language Result Execution time Memory
409868 2021-05-21T17:34:49 Z soba Swapping Cities (APIO20_swap) C++14
7 / 100
108 ms 6968 KB
#include "swap.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int ans;
vector<pair<int,int> >vp;
int fromzerotoX[100001];
int n , m;
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
    n=N;
    m=M;
        for(int i = 0 ; i < V.size() ; i++)
        {
            fromzerotoX[V[i]]=W[i];
            vp.push_back({W[i], V[i]});
        }
        ans=*max_element(W.begin() , W.end());
        sort(vp.begin() , vp.end());
}

int getMinimumFuelCapacity(int X, int Y){
    if(m!=n-1)
        return ans;
    if(n<4)return -1;
    int x=X , y=Y , out=0;
    if(x>y)
    {
        swap(x,y);
    }
    if(x==0)
    {
        int c=0;
        out=max(out , fromzerotoX[y]);
        for(auto u :vp )
        {
            if(u.second!=y)
            {
                out=max(out , u.first);
                c++;
            }
            if(c==2)
                break;
        }
        return out;
    }
    out=max( fromzerotoX[x] , fromzerotoX[y]);
    for(auto u :vp )
    {
        if(u.second!=y&&u.second!=x)
        {
            out=max(out , u.first);
            break;
        }
    }
    return out;
}

Compilation message

swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:12:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for(int i = 0 ; i < V.size() ; i++)
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory 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 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 104 ms 6748 KB Output is correct
4 Correct 104 ms 6764 KB Output is correct
5 Correct 108 ms 6968 KB Output is correct
6 Correct 103 ms 6684 KB Output is correct
7 Correct 107 ms 6944 KB Output is correct
8 Correct 106 ms 6760 KB Output is correct
9 Correct 107 ms 6820 KB Output is correct
10 Correct 105 ms 6900 KB Output is correct
# Verdict Execution time Memory 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 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -