forked from danielmitre/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC.cpp
56 lines (44 loc) · 1022 Bytes
/
C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 600;
const int INF = 999999999;
void inicia(int N){
}
int main(){
int N, M, I;
while (scanf(" %d %d %d", &N, &M, &I) != EOF){
int idades[MAXN];
int menorchefe[MAXN];
bool boss[MAXN][MAXN] = {false};
for (int i=0; i<=N; i++){
idades[i] = INF;
menorchefe[i] = INF;
}
for (int i=1; i<=N; i++) scanf(" %d", &idades[i]);
int x, y;
for (int i=0; i<M; i++){
scanf(" %d %d", &x, &y);
boss[y][x] = true;
menorchefe[y] = min(menorchefe[y], idades[x]);
}
char op;
int arg1, arg2;
for (int i=0; i<I; i++){
scanf(" %c", &op);
if (op == 'P'){
scanf(" %d", &arg1);
printf("%d\n", menorchefe[arg1]);
} else {
scanf(" %d %d", &arg1, &arg2);
int menorA = INF, menorB = INF;
for (int chefe=1; chefe<=N; chefe++){
if (boss[arg1][chefe]){
swap(boss[arg1][chefe], boss[chefe][arg1]);
swap(menorchefe[arg1], menorchefe[chefe]);
}
}
}
}
}
return 0;
}