Submission #849138

# Submission time Handle Problem Language Result Execution time Memory
849138 2023-09-14T06:49:50 Z Hyojin Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
352 ms 65296 KB
#include <bits/stdc++.h>
using namespace std;
#define bit(n,i) ((n>>i)&1) 
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define ep emplace_back
#define pii pair<int,int>
#define piii pair<int,pii> 
#define fi first
#define se second
#define ll long long
#define debug(x) cerr << #x << ' ' << x << '\n'
#define dbg(x) cerr<<#x<<' '<<x<<' '
const int base=31;
const int MOD=1e9+7;
const int N=1e5+5;
void setIO(const string &NAME)
{
	if (NAME.size())
	{
		freopen((NAME+".inp").c_str(),"r",stdin);
		freopen((NAME+".out").c_str(),"w",stdout);
	}
}
pair<ll,ll>d[N];
bool vis[N];
vector<pii>adj[N];
priority_queue<pair<ll,int>>pq;
ll travel_plan(int n,int m,int r[][2],int l[],int k,int p[])
{
	for (int i=0;i<m;i++)
	{
		int u=r[i][0],v=r[i][1];
		adj[u].pb({v,l[i]});
		adj[v].pb({u,l[i]});
	}
	for (int i=0;i<n;i++) d[i]={1e18,1e18};	
	for (int i=0;i<k;i++)
	{
		pq.push({0,p[i]});
		d[p[i]]={0,0};
	}
	while (pq.size())
	{
		auto [cost,u]=pq.top();
		cost=-cost;
		pq.pop();
		if (vis[u]) continue;
		vis[u]=1;
		for (int i=0;i<adj[u].size();i++)
		{
			int v=adj[u][i].fi,w=adj[u][i].se;
			if (cost+w<d[v].se)
			{
				d[v].se=cost+w;
				if (d[v].se<d[v].fi) swap(d[v].fi,d[v].se);
				if (d[v].se!=1e18) pq.push({-d[v].se,v});
			}
		}
	}
	return d[0].se;
}

Compilation message

crocodile.cpp: In function 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:50:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for (int i=0;i<adj[u].size();i++)
      |                ~^~~~~~~~~~~~~~
crocodile.cpp: In function 'void setIO(const string&)':
crocodile.cpp:21:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   freopen((NAME+".inp").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:22:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   freopen((NAME+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6744 KB Output is correct
4 Correct 2 ms 6744 KB Output is correct
5 Correct 2 ms 6744 KB Output is correct
6 Correct 1 ms 6904 KB Output is correct
7 Correct 2 ms 6744 KB Output is correct
8 Correct 1 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6744 KB Output is correct
4 Correct 2 ms 6744 KB Output is correct
5 Correct 2 ms 6744 KB Output is correct
6 Correct 1 ms 6904 KB Output is correct
7 Correct 2 ms 6744 KB Output is correct
8 Correct 1 ms 6744 KB Output is correct
9 Correct 3 ms 7000 KB Output is correct
10 Correct 1 ms 6744 KB Output is correct
11 Correct 2 ms 6744 KB Output is correct
12 Correct 3 ms 7000 KB Output is correct
13 Correct 3 ms 7000 KB Output is correct
14 Correct 1 ms 6744 KB Output is correct
15 Correct 1 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 1 ms 6744 KB Output is correct
3 Correct 1 ms 6744 KB Output is correct
4 Correct 2 ms 6744 KB Output is correct
5 Correct 2 ms 6744 KB Output is correct
6 Correct 1 ms 6904 KB Output is correct
7 Correct 2 ms 6744 KB Output is correct
8 Correct 1 ms 6744 KB Output is correct
9 Correct 3 ms 7000 KB Output is correct
10 Correct 1 ms 6744 KB Output is correct
11 Correct 2 ms 6744 KB Output is correct
12 Correct 3 ms 7000 KB Output is correct
13 Correct 3 ms 7000 KB Output is correct
14 Correct 1 ms 6744 KB Output is correct
15 Correct 1 ms 6744 KB Output is correct
16 Correct 294 ms 60380 KB Output is correct
17 Correct 58 ms 16716 KB Output is correct
18 Correct 62 ms 18012 KB Output is correct
19 Correct 352 ms 65296 KB Output is correct
20 Correct 208 ms 52048 KB Output is correct
21 Correct 27 ms 12368 KB Output is correct
22 Correct 224 ms 49488 KB Output is correct