Submission #682942

# Submission time Handle Problem Language Result Execution time Memory
682942 2023-01-17T10:10:02 Z Nursik Swapping Cities (APIO20_swap) C++14
6 / 100
156 ms 41568 KB
#include "swap.h"

#include <stdio.h>
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define mp make_pair
#define f first
#define s second
#define pb push_back

const int maxn = 1e6 + 200;

int subtask2 = 1, subtask1 = 1;
multiset<int> setik;
vector<pair<int, int>> g[maxn];
int ver, reb;
void init(int n, int m, vector<int> u, vector<int> v, vector<int> w) {
    for (int i = 0; i < m; ++i){
        int x = u[i], y = v[i];
        g[x].pb(mp(y, w[i]));
        g[y].pb(mp(x, w[i]));
    }
    for (auto it : u){
        subtask2 &= (it == 0);
    }
    for (auto it : w){
        setik.insert(it);
    }
    for (int i = 1; i <= n; ++i){
        int sz = (int)g[i].size();
        subtask1 &= (sz <= 2);
    }
    ver = n, reb = m;
}

int getMinimumFuelCapacity(int x, int y) {
    if (subtask1 == 1){
        if (reb == ver - 1){
            return -1;
        }
        else{
            return *setik.rbegin();
        }
    }
    if (subtask2 == 1){
    if (x == 0){
        int cur = g[y][0].s;
        setik.erase(setik.find(cur));
        int sz = (int)setik.size();
        if (sz == 0){
            setik.insert(cur);
            return -1;
        }
        sz -= 1;
        int cur2 = *setik.begin();
        setik.erase(setik.find(cur2));
        if (sz == 0){
            setik.insert(cur);
            setik.insert(cur2);
            return -1;
        }
        sz -= 1;
        int cur3 = *setik.begin();
        setik.insert(cur);
        setik.insert(cur2);
        return max({cur, cur2, cur3});
    }
    int cur = g[x][0].s;
    int cur2 = g[y][0].s;
    setik.erase(setik.find(cur));
    setik.erase(setik.find(cur2));
    if ((int)setik.size() == 0){
        setik.insert(cur);
        setik.insert(cur2);
        return -1;
    }
    int cur3 = *setik.begin();
    setik.insert(cur);
    setik.insert(cur2);
    return max({cur, cur2, cur3});
    }
}

Compilation message

swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:108:1: warning: control reaches end of non-void function [-Wreturn-type]
  108 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23816 KB Output is correct
5 Correct 16 ms 23808 KB Output is correct
6 Correct 13 ms 23856 KB Output is correct
7 Correct 12 ms 23816 KB Output is correct
8 Correct 16 ms 23820 KB Output is correct
9 Correct 72 ms 33396 KB Output is correct
10 Correct 106 ms 35536 KB Output is correct
11 Correct 83 ms 35312 KB Output is correct
12 Correct 91 ms 35968 KB Output is correct
13 Correct 84 ms 35980 KB Output is correct
14 Correct 73 ms 33664 KB Output is correct
15 Correct 131 ms 39776 KB Output is correct
16 Correct 127 ms 39520 KB Output is correct
17 Correct 139 ms 40116 KB Output is correct
18 Correct 145 ms 40152 KB Output is correct
19 Correct 62 ms 30724 KB Output is correct
20 Correct 147 ms 40732 KB Output is correct
21 Correct 156 ms 40964 KB Output is correct
22 Correct 136 ms 41480 KB Output is correct
23 Correct 143 ms 41568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Incorrect 124 ms 35808 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23816 KB Output is correct
5 Correct 16 ms 23808 KB Output is correct
6 Correct 13 ms 23856 KB Output is correct
7 Correct 12 ms 23816 KB Output is correct
8 Correct 16 ms 23820 KB Output is correct
9 Incorrect 12 ms 23764 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23816 KB Output is correct
5 Correct 16 ms 23808 KB Output is correct
6 Correct 13 ms 23856 KB Output is correct
7 Correct 12 ms 23816 KB Output is correct
8 Correct 16 ms 23820 KB Output is correct
9 Correct 72 ms 33396 KB Output is correct
10 Correct 106 ms 35536 KB Output is correct
11 Correct 83 ms 35312 KB Output is correct
12 Correct 91 ms 35968 KB Output is correct
13 Correct 84 ms 35980 KB Output is correct
14 Correct 73 ms 33664 KB Output is correct
15 Correct 131 ms 39776 KB Output is correct
16 Correct 127 ms 39520 KB Output is correct
17 Correct 139 ms 40116 KB Output is correct
18 Correct 145 ms 40152 KB Output is correct
19 Incorrect 124 ms 35808 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -