#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define F first
#define S second
int n, m, flag = true;
vector < int > u, v, w;
vector < int > vc[200045];
pair < int , pair< int, int > > p[200045];
void init(int N, int M,
std::vector<int> U, std::vector<int> V, std::vector<int> W) {
int i;
n = N;m = M;u = U;v = V;w = W;
for( i = 0; i < m; i ++ ){
p[i].second.F=u[i];
p[i].second.S=v[i];
p[i].first=w[i];
}
sort( p, p + m );
}
bool vis[200045];
int getMinimumFuelCapacity(int X, int Y) {
map < int, int > mp;
int i;
flag = false;
mp.clear();
for( i = 0; i < n; i ++ )
vc[i].clear();
for( i = 0; i < m; i ++ ){
vc[ p[i].second.F ].pb( p[i].second.S );
vc[ p[i].second.S ].pb( p[i].second.F );
mp[p[i].second.F] = 1;
mp[ p[i].second.S ] = 1;
if( vc[ p[i].second.F ].size() == 3 || vc[p[i].S.S].size() == 3 ){
flag = true;
}
if( mp.size() == i+1 && mp[X] == mp[Y] && mp[X] == 1 ){
return p[i].first;
}
if( mp[X] == mp[Y] && mp[X] == 1 && flag == true )
return p[i].first;
}
return -1;
}
Compilation message
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:40:17: warning: comparison of integer expressions of different signedness: 'std::map<int, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
40 | if( mp.size() == i+1 && mp[X] == mp[Y] && mp[X] == 1 ){
| ~~~~~~~~~~^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4996 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
5 ms |
5068 KB |
Output is correct |
6 |
Correct |
5 ms |
5068 KB |
Output is correct |
7 |
Correct |
5 ms |
5068 KB |
Output is correct |
8 |
Correct |
5 ms |
5068 KB |
Output is correct |
9 |
Correct |
201 ms |
15484 KB |
Output is correct |
10 |
Correct |
545 ms |
17544 KB |
Output is correct |
11 |
Correct |
569 ms |
17388 KB |
Output is correct |
12 |
Correct |
689 ms |
18028 KB |
Output is correct |
13 |
Correct |
521 ms |
18096 KB |
Output is correct |
14 |
Execution timed out |
2091 ms |
15912 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Execution timed out |
2060 ms |
21792 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4996 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
5 ms |
5068 KB |
Output is correct |
6 |
Correct |
5 ms |
5068 KB |
Output is correct |
7 |
Correct |
5 ms |
5068 KB |
Output is correct |
8 |
Correct |
5 ms |
5068 KB |
Output is correct |
9 |
Correct |
3 ms |
5000 KB |
Output is correct |
10 |
Incorrect |
4 ms |
5068 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5000 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4996 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
5 ms |
5068 KB |
Output is correct |
7 |
Correct |
5 ms |
5068 KB |
Output is correct |
8 |
Correct |
5 ms |
5068 KB |
Output is correct |
9 |
Correct |
5 ms |
5068 KB |
Output is correct |
10 |
Correct |
201 ms |
15484 KB |
Output is correct |
11 |
Correct |
545 ms |
17544 KB |
Output is correct |
12 |
Correct |
569 ms |
17388 KB |
Output is correct |
13 |
Correct |
689 ms |
18028 KB |
Output is correct |
14 |
Correct |
521 ms |
18096 KB |
Output is correct |
15 |
Incorrect |
4 ms |
5068 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4996 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
5 ms |
5068 KB |
Output is correct |
6 |
Correct |
5 ms |
5068 KB |
Output is correct |
7 |
Correct |
5 ms |
5068 KB |
Output is correct |
8 |
Correct |
5 ms |
5068 KB |
Output is correct |
9 |
Correct |
201 ms |
15484 KB |
Output is correct |
10 |
Correct |
545 ms |
17544 KB |
Output is correct |
11 |
Correct |
569 ms |
17388 KB |
Output is correct |
12 |
Correct |
689 ms |
18028 KB |
Output is correct |
13 |
Correct |
521 ms |
18096 KB |
Output is correct |
14 |
Execution timed out |
2091 ms |
15912 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5000 KB |
Output is correct |
2 |
Correct |
3 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4996 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
5 ms |
5068 KB |
Output is correct |
7 |
Correct |
5 ms |
5068 KB |
Output is correct |
8 |
Correct |
5 ms |
5068 KB |
Output is correct |
9 |
Correct |
5 ms |
5068 KB |
Output is correct |
10 |
Correct |
201 ms |
15484 KB |
Output is correct |
11 |
Correct |
545 ms |
17544 KB |
Output is correct |
12 |
Correct |
569 ms |
17388 KB |
Output is correct |
13 |
Correct |
689 ms |
18028 KB |
Output is correct |
14 |
Correct |
521 ms |
18096 KB |
Output is correct |
15 |
Execution timed out |
2091 ms |
15912 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |