File tree Expand file tree Collapse file tree 12 files changed +544
-10
lines changed
Expand file tree Collapse file tree 12 files changed +544
-10
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,18 @@ using namespace std;
1818#define MP make_pair
1919#define FF first
2020#define SS second
21- #define max (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
22- #define min (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
2333#define FIO \
2434 ios_base::sync_with_stdio (false ); \
2535 cin.tie(NULL ); \
Original file line number Diff line number Diff line change @@ -18,8 +18,18 @@ using namespace std;
1818#define MP make_pair
1919#define FF first
2020#define SS second
21- #define max (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
22- #define min (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
2333#define FIO \
2434 ios_base::sync_with_stdio (false ); \
2535 cin.tie(NULL ); \
Original file line number Diff line number Diff line change @@ -18,8 +18,18 @@ using namespace std;
1818#define MP make_pair
1919#define FF first
2020#define SS second
21- #define max (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
22- #define min (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
2333#define FIO \
2434 ios_base::sync_with_stdio (false ); \
2535 cin.tie(NULL ); \
Original file line number Diff line number Diff line change @@ -18,8 +18,18 @@ using namespace std;
1818#define MP make_pair
1919#define FF first
2020#define SS second
21- #define max (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
22- #define min (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
2333#define FIO \
2434 ios_base::sync_with_stdio (false ); \
2535 cin.tie(NULL ); \
Original file line number Diff line number Diff line change 1+ /*
2+ Problem Link:
3+ #############################################
4+ Author: Siddharth Mishra
5+ GitHub: https://github.com/Hard-Coder05
6+ #############################################
7+ */
8+ #include < bits/stdc++.h>
9+ using namespace std ;
10+ #define endl " \n "
11+ #define MOD 1000000007
12+ #define INF INT_MAX
13+ #define vi vector<int >
14+ #define pii pair<int , int >
15+ #define ll long long
16+ #define ld long double
17+ #define PB push_back
18+ #define MP make_pair
19+ #define FF first
20+ #define SS second
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
33+ #define FIO \
34+ ios_base::sync_with_stdio (false ); \
35+ cin.tie(NULL ); \
36+ cout.tie(NULL );
37+
38+ int main ()
39+ {
40+ FIO;
41+ #ifndef ONLINE_JUDGE
42+ freopen (" input.txt" , " r" , stdin);
43+ freopen (" output.txt" , " w" , stdout);
44+ #endif
45+ ll tc;
46+ cin >> tc;
47+ while (tc--)
48+ {
49+ ll a, b, c, d, k;
50+ cin >> a >> b >> c >> d >> k;
51+ ll step = abs (a - c) + abs (b - d);
52+ if (k >= step && (k - step) % 2 == 0 )
53+ cout << " YES" << endl;
54+ else
55+ cout << " NO" << endl;
56+ }
57+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Problem Link:
3+ #############################################
4+ Author: Siddharth Mishra
5+ GitHub: https://github.com/Hard-Coder05
6+ #############################################
7+ */
8+ #include < bits/stdc++.h>
9+ using namespace std ;
10+ #define endl " \n "
11+ #define MOD 1000000007
12+ #define INF INT_MAX
13+ #define vi vector<int >
14+ #define pii pair<int , int >
15+ #define ll long long
16+ #define ld long double
17+ #define PB push_back
18+ #define MP make_pair
19+ #define FF first
20+ #define SS second
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
33+ #define FIO \
34+ ios_base::sync_with_stdio (false ); \
35+ cin.tie(NULL ); \
36+ cout.tie(NULL );
37+
38+ int main ()
39+ {
40+ FIO;
41+ #ifndef ONLINE_JUDGE
42+ freopen (" input.txt" , " r" , stdin);
43+ freopen (" output.txt" , " w" , stdout);
44+ #endif
45+ ll tc;
46+ cin >> tc;
47+ while (tc--)
48+ {
49+ ll n, k;
50+ cin >> n >> k;
51+ string s;
52+ cin >> s;
53+ ll q[k];
54+ for (int i = 0 ; i < k; i++)
55+ {
56+ cin >> q[i];
57+ }
58+ ll cur = 0 ;
59+ for (int i = 0 ; i < n - 1 ; i++)
60+ {
61+ if (s[i] != s[i + 1 ])
62+ {
63+ cur += 1 ;
64+ }
65+ else
66+ {
67+ cur += 2 ;
68+ }
69+ }
70+ for (int i = 0 ; i < k; i++)
71+ {
72+ ll par = q[i];
73+ par--;
74+ if (par == 0 )
75+ {
76+ if (s[par] == ' 0' )
77+ {
78+ if (par + 1 < n and s[par + 1 ] == ' 1' )
79+ {
80+ cur -= 1 ;
81+ cur += 2 ;
82+ }
83+ else if (par + 1 < n and s[par + 1 ] == ' 0' )
84+ {
85+ cur -= 2 ;
86+ cur += 1 ;
87+ }
88+ s[par] = ' 1' ;
89+ }
90+ else
91+ {
92+ if (par + 1 < n and s[par + 1 ] == ' 1' )
93+ {
94+ cur -= 2 ;
95+ cur += 1 ;
96+ }
97+ else if (par + 1 < n and s[par + 1 ] == ' 0' )
98+ {
99+ cur -= 1 ;
100+ cur += 2 ;
101+ }
102+ s[par] = ' 0' ;
103+ }
104+ }
105+ else if (par == n - 1 )
106+ {
107+ if (s[par] == ' 0' )
108+ {
109+ if (par - 1 >= 0 and s[par - 1 ] == ' 1' )
110+ {
111+ cur -= 1 ;
112+ cur += 2 ;
113+ }
114+ else if (par - 1 >= 0 and s[par - 1 ] == ' 0' )
115+ {
116+ cur -= 2 ;
117+ cur += 1 ;
118+ }
119+ s[par] = ' 1' ;
120+ }
121+ else
122+ {
123+ if (par - 1 >= 0 and s[par - 1 ] == ' 1' )
124+ {
125+ cur -= 2 ;
126+ cur += 1 ;
127+ }
128+ else if (par - 1 >= 0 and s[par - 1 ] == ' 0' )
129+ {
130+ cur -= 1 ;
131+ cur += 2 ;
132+ }
133+ s[par] = ' 0' ;
134+ }
135+ }
136+ else
137+ {
138+ if (s[par] == ' 0' )
139+ {
140+ if (s[par - 1 ] == ' 0' )
141+ {
142+ cur -= 2 ;
143+ cur += 1 ;
144+ }
145+ else
146+ {
147+ cur -= 1 ;
148+ cur += 2 ;
149+ }
150+ if (s[par + 1 ] == ' 0' )
151+ {
152+ cur -= 2 ;
153+ cur += 1 ;
154+ }
155+ else
156+ {
157+ cur -= 1 ;
158+ cur += 2 ;
159+ }
160+ s[par] = ' 1' ;
161+ }
162+ else
163+ {
164+ if (s[par - 1 ] == ' 0' )
165+ {
166+ cur -= 1 ;
167+ cur += 2 ;
168+ }
169+ else
170+ {
171+ cur -= 2 ;
172+ cur += 1 ;
173+ }
174+ if (s[par + 1 ] == ' 0' )
175+ {
176+ cur -= 1 ;
177+ cur += 2 ;
178+ }
179+ else
180+ {
181+ cur -= 2 ;
182+ cur += 1 ;
183+ }
184+ s[par] = ' 0' ;
185+ }
186+ }
187+ cout << cur << " \n " ;
188+ }
189+ }
190+ }
You can’t perform that action at this time.
0 commit comments