# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
254301491 |
Practice:
shajal_23 |
1942C1
- 48
|
C++17 (GCC 7-32)
|
Accepted
|
92 ms
|
1576 KB
|
2024-03-31 15:43:29 |
2024-03-31 15:43:29 |
|
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i, n) for (ll i = 0; i < (n); i++)
#define vll vector<long long>
#define SORT(a) sort(a.begin(), a.end())
#define inp cin >>
#define ii >>
#define out cout <<
#define oo <<
#define nl << "\n"
#define newLine cout << endl;
#define space << " "
#define spc << " " <<
/////////////////////////////////////////////////////////////////////////////////
void SOLVE()
{
ll n, x, y;
cin >> n >> x >> y;
vll v(x);
loop(i, x) cin >> v[i];
SORT(v);
ll ans = (x - 2);
loop(i, x)
{
if (i == x - 1)
{
if ((v[i] + 2) % n == v[0])
ans++;
}
else
{
if (v[i] + 2 == v[i + 1]) //one gap between two indices
ans++;
}
}
out ans nl;
}
/////////////////////////////////////////////////////////////////////////////////
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(NULL);
ll t = 1;
cin >> t;
while (t--)
SOLVE();
}
Click to see test details