Submission #773084

# Submission time Handle Problem Language Result Execution time Memory
773084 2023-07-04T14:52:48 Z AmirElarbi Cyberland (APIO23_cyberland) C++17
15 / 100
803 ms 10152 KB
#include <bits/stdc++.h>
#define ve vector
#define vi vector<int>
#define vii vector<ii>
#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define INF 1e18+7
#define pb push_back
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
const int MOD = 1e9+7;
const int nax = 2e5+5;
const int MAXL = 20+5;
void readio(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
#include "cyberland.h"

vii adj[nax];
double solve(int n, int m, int k, int h, vi x, vi y, vi c, vi arr) {
    memset(adj, {}, sizeof adj);
    for (int i = 0; i < m; ++i)
    {
        adj[x[i]].pb({y[i], c[i]});
        adj[y[i]].pb({x[i], c[i]});
    }
    ve<ll> dist(n, INF);
    priority_queue<pair<ll,int>, ve<pair<ll,int>>, greater<pair<ll,int>>> pq;
    for (int i = 0; i < n; ++i)
    {
        if(arr[i] == 0 || !i){
            dist[i] = 0;
            pq.push({0, i});        
        }
    }
    while(!pq.empty()){
        int u = pq.top().se;
        ll cst = pq.top().fi;
        pq.pop();
        if(dist[u] != cst) continue;
        for(auto x : adj[u]){
            if(dist[u]+x.se < dist[x.fi]){
                dist[x.fi] = dist[u]+x.se;
                pq.push({dist[x.fi], x.fi});
            }
        }
    }
    if(dist[h] == INF) return -1;
    return dist[h];
}

Compilation message

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:31:31: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'class std::vector<std::pair<int, int> >' with no trivial copy-assignment [-Wclass-memaccess]
   31 |     memset(adj, {}, sizeof adj);
      |                               ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'class std::vector<std::pair<int, int> >' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
cyberland.cpp: In function 'void readio()':
cyberland.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cyberland.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 803 ms 5756 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 6980 KB Correct.
2 Correct 35 ms 7256 KB Correct.
3 Correct 32 ms 7112 KB Correct.
4 Correct 35 ms 7244 KB Correct.
5 Correct 35 ms 7260 KB Correct.
6 Correct 21 ms 6988 KB Correct.
7 Correct 26 ms 7588 KB Correct.
8 Correct 12 ms 6784 KB Correct.
9 Correct 110 ms 7152 KB Correct.
10 Correct 103 ms 7160 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 7288 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 10152 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 6896 KB Correct.
2 Correct 34 ms 7248 KB Correct.
3 Correct 33 ms 7120 KB Correct.
4 Correct 22 ms 7116 KB Correct.
5 Correct 97 ms 6916 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 7012 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 6964 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 6984 KB Wrong Answer.
2 Halted 0 ms 0 KB -