forked from SharmaManish/Spoj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQTREE.cpp
More file actions
61 lines (45 loc) · 1.84 KB
/
QTREE.cpp
File metadata and controls
61 lines (45 loc) · 1.84 KB
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
57
58
59
60
61
#include<iostream>
#include<stdio.h>
#include<cstdlib>
int main()
{
int n,t,a,b,c,j,k,boo=1;
char* s;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int cost[n-1][3];
for(int i=0;i<n-1;i++)
scanf("%d%d%d",&a,&b,&c);
while(boo)
{
scanf("%s",&s);
if(s[0]='C')
{
char x=s[7];
char y=s[9];
j=atoi(x);
k=atoi(y);
cost[j+1][2]=k;
}
else if(s[0]='Q')
{
char* x=s[6];
char* y=s[8];
j=atoi(x);
k=atoi(y);
for(int i=0;i<n-1;i++)
{
if(cost[i][0]==j && cost[i][1]==k)
printf("%d\n",cost[i][2]);
}
}
else if(s=="DONE")
boo=0;
}
printf("\n");
}
system ("pause");
return 0;
}