-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbomb.cpp
79 lines (69 loc) · 1004 Bytes
/
bomb.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdio.h>
#include <iostream>
//#include <math.h>
#include <string>
#include <vector>
#include <bits/stdc++.h>
int main()
{
int n,t;
scanf("%d%d",&n,&t);
int arr[504];
//std :: vector<int> vec;
int count=0;
int flag=0;
int temp[100];
int k=1;
while(n--)
{
while(t--)
{
int a ,b;
scanf("%d%d",&a,&b);
//printf("%d %d\n",a,b);
temp[k]=a;
k++;
temp[k]=b;
k++;
for (int i = a; i <= b; i++)
{
if(arr[i] == 1)
{
arr[i] = 9;
flag++;
if(arr[i-1] == 9 && arr[i] ==9)
{
flag-=1;
//printf("yes\n");
}
}
else
arr[i] = 1;
count++;
}
//printf("%d\n",flag);
}
int check = k/2;
int i;
int j=1;
while(check--)
{
int test=0;
//printf("%d %d\n",temp[j],temp[j+1]);
for(i = temp[j]; i <= temp[j+1] ; i++)
{
if(arr[i]==9)
{
test++;
}
}
if(test==0)
{
flag++;
}
j=j+2;
//printf("%d\n",j );
}
printf("%d\n",flag);
}
}