Submission #330654

# Submission time Handle Problem Language Result Execution time Memory
330654 2020-11-26T04:57:16 Z egas Swapping Cities (APIO20_swap) C++14
13 / 100
1212 ms 42868 KB
#include <bits/stdc++.h>
using namespace std;
map<int,set<int>> adj;
multiset<int> ms;
map<pair<int,int>,int> edwt;
int SUBTASK1=0;
bool isCyc=0;
bool isSubtask1=true;
bool isCycle(){
	for(auto x:adj){
		if(x.second.size()<=1)return false;
		if(x.second.size()>2)isSubtask1=false;
	}
	return true;
}
void init(int N, int M,std::vector<int> U, std::vector<int> V, std::vector<int> W) {
	for(int i=0;i<M;i++){
		int x=U[i];
		int y=V[i];
		int z=W[i];
		ms.insert(z);
		edwt[{min(x,y),max(x,y)}]=z;
		SUBTASK1=max(SUBTASK1,(W[i]));
		adj[x].insert(y);
		adj[y].insert(x);
	}
	isCyc=isCycle();
}
 
int getMinimumFuelCapacity(int X, int Y) {
	if(isSubtask1){
		if(isCyc){
			return SUBTASK1;
		}else
			return -1;
	}else{
		if(ms.size()<=2){
			return -1;
		}
		if(X==0){
			int two = edwt[{0,Y}];
			int res=two;
			ms.erase(ms.find(two));
			auto temp = ms.begin();
			res=max(res,(*temp));
			temp++;
			res=max(res,(*temp));
			ms.insert(two);
			return res;
		}
		int one = edwt[{0,X}];
		int two = edwt[{0,Y}];
		int res=max(one,two);
		ms.erase(ms.find(one));
		ms.erase(ms.find(two));
		if(ms.size()>0)
			res=max(res,(*ms.begin()));
		ms.insert(one);
		ms.insert(two);
		return res;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 3 ms 620 KB Output is correct
7 Correct 3 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 299 ms 25580 KB Output is correct
10 Correct 391 ms 31212 KB Output is correct
11 Correct 384 ms 30776 KB Output is correct
12 Correct 422 ms 32364 KB Output is correct
13 Correct 432 ms 32364 KB Output is correct
14 Correct 307 ms 25580 KB Output is correct
15 Correct 464 ms 33288 KB Output is correct
16 Correct 457 ms 32524 KB Output is correct
17 Correct 469 ms 34260 KB Output is correct
18 Correct 468 ms 34260 KB Output is correct
19 Correct 90 ms 8940 KB Output is correct
20 Correct 482 ms 34540 KB Output is correct
21 Correct 496 ms 33448 KB Output is correct
22 Correct 506 ms 35668 KB Output is correct
23 Correct 491 ms 35664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1212 ms 37376 KB Output is correct
4 Correct 1173 ms 39144 KB Output is correct
5 Correct 1210 ms 38144 KB Output is correct
6 Correct 1174 ms 42868 KB Output is correct
7 Correct 1186 ms 42728 KB Output is correct
8 Correct 1165 ms 41100 KB Output is correct
9 Correct 1167 ms 42216 KB Output is correct
10 Correct 1177 ms 40788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 3 ms 620 KB Output is correct
7 Correct 3 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 299 ms 25580 KB Output is correct
10 Correct 391 ms 31212 KB Output is correct
11 Correct 384 ms 30776 KB Output is correct
12 Correct 422 ms 32364 KB Output is correct
13 Correct 432 ms 32364 KB Output is correct
14 Correct 307 ms 25580 KB Output is correct
15 Correct 464 ms 33288 KB Output is correct
16 Correct 457 ms 32524 KB Output is correct
17 Correct 469 ms 34260 KB Output is correct
18 Correct 468 ms 34260 KB Output is correct
19 Correct 1212 ms 37376 KB Output is correct
20 Correct 1173 ms 39144 KB Output is correct
21 Correct 1210 ms 38144 KB Output is correct
22 Correct 1174 ms 42868 KB Output is correct
23 Correct 1186 ms 42728 KB Output is correct
24 Correct 1165 ms 41100 KB Output is correct
25 Correct 1167 ms 42216 KB Output is correct
26 Correct 1177 ms 40788 KB Output is correct
27 Incorrect 3 ms 620 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)