Submission #892461

# Submission time Handle Problem Language Result Execution time Memory
892461 2023-12-25T11:20:47 Z AgentPengin Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
350 ms 55236 KB
/**
 *    author:  AgentPengin ( Độc cô cầu bại )
 *    created: 23.12.2022 10:08:02
 *    too lazy to update time
**/
#include "crocodile.h"
#include<bits/stdc++.h>
#define EL '\n'
#define fi first
#define se second
#define NAME "TASK"
#define ll long long
#define lcm(a,b) (a/gcd(a,b))*b
#define db(val) "["#val" = " << (val) << "] "
#define bend(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()
#define ex exit(0)
#define pii pair<ll,int>

using namespace std;

const ll mod = 1e9 + 7;
const int inf = 0x1FFFFFFF;
const int MAXN = 1e5 + 5;

int n,m,k;
pair<int,int> dist[MAXN];
vector<pair<int,int>> adj[MAXN];
priority_queue<pii,vector<pii>,greater<pii>> pq;

int travel_plan(int N, int M, int R[][2], int W[], int K, int E[]) {
	memset(dist,0x3f,sizeof dist);
	n = N;
	m = M;
	for (int i = 0;i < m;i++) {
		int u = R[i][0],v = R[i][1],l = W[i];
		adj[u].emplace_back(v,l);
		adj[v].emplace_back(u,l);    	
	}
	k = K;
	for (int i = 0;i < k;i++) {
		int u = E[i];
		pq.push(make_pair(0,u));
    	dist[u] = make_pair(0,0);
	}
	while(!pq.empty()) {
    	int u = pq.top().se;
    	int du = pq.top().fi;
    	pq.pop();
    	if (du != dist[u].se) continue;
    	for (auto it : adj[u]) {
    		int v = it.fi;
    		int uv = it.se;
    		if (dist[v].fi > du + uv) {
    			if (dist[v].se > dist[v].fi) dist[v].se = dist[v].fi;
    			dist[v].fi = du + uv;
    			pq.push({dist[v].se,v});
    		} else {
    			if (du + uv < dist[v].se) {
    				dist[v].se = du + uv;
    				pq.push({dist[v].se,v});
    			}
    		}
    	}
    }
    return dist[0].se;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:32:30: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'struct std::pair<int, int>' with no trivial copy-assignment [-Wclass-memaccess]
   32 |  memset(dist,0x3f,sizeof dist);
      |                              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from crocodile.cpp:7:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'struct std::pair<int, int>' declared here
  211 |     struct pair
      |            ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6744 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6744 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 3 ms 7028 KB Output is correct
13 Correct 3 ms 7004 KB Output is correct
14 Correct 1 ms 6744 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 2 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6744 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Correct 2 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 3 ms 7028 KB Output is correct
13 Correct 3 ms 7004 KB Output is correct
14 Correct 1 ms 6744 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 275 ms 49880 KB Output is correct
17 Correct 65 ms 15572 KB Output is correct
18 Correct 83 ms 17116 KB Output is correct
19 Correct 350 ms 55236 KB Output is correct
20 Correct 186 ms 41296 KB Output is correct
21 Correct 38 ms 9680 KB Output is correct
22 Incorrect 251 ms 37872 KB Output isn't correct
23 Halted 0 ms 0 KB -