QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#779036 | #6765. Don't Really Like How The Story Ends | zzz666 | WA | 116ms | 3632kb | C++17 | 1.7kb | 2024-11-24 17:10:01 | 2024-11-24 17:10:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lll _int128
#define ull unsigned long long
#define PB push_back
#define fi first
#define se second
#define _int _int128
#define fr(i,a,b) for(int i = a ; i <= b ; i++)
#define rp(i,a,b) for(int i = a ; i >= b ; i--)
#define frp(i,a,b) for(int i = 1 ; i < b ; i ++ )
#define re read()
#define db double
#define ld long double
#define lowbit(x) x&(-x)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int inf = 0x3f3f3f3f;
const ll N = 2e6+10;
const ll mod = 1e9+7;
inline ll read()
{
ll x=0,f=0;
char ch=getchar();
while (!isdigit(ch))
f|=(ch =='-'),ch = getchar();
while (isdigit(ch))
x=(x<<1)+(x<<3)+(ch^= 48),ch = getchar();
return f?-x:x;
}
inline void write(ll x)
{
if(x < 0)
putchar('-'),x=-x;
if(x > 9)
write(x/10);
putchar(x%10 + 48);
}
inline void W(ll x,char ch)
{
write(x);
putchar(ch);
}
ll lcm(int a,int b)
{
return a*b / __gcd(a,b);
}
struct edge{
int x,y;
}e[N];
ll h[N];
int d[100005][105];
int w[100005];
int vis[1000005];
int cnt;
int n,m,q;
int ans =0 ;
map<pair<int,int>,int>mp;
inline void slove()
{
ans = 0;
cin>>n>>m;
mp.clear();
fr(i,1,m)
{
int x,y;
cin>>x>>y;
if(x==y) continue;
if(x > y) swap(x,y);
if( x == y-1 || (x==1&&y==n))
mp[{x,y}]++;
}
if(n==1)
{
cout<<0<<endl;
return;
}
fr(i,1,n-1)
{
if(!mp[{i,i+1}]) ans++;
}
if(mp[{1,n}] && ans!=0) ans--;
cout<<ans<<endl;
}
int main()
{
IOS
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
int tcase = 1;
cin>>tcase;
while(tcase--)
{
slove();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3568kb
input:
3 2 3 1 1 1 2 2 1 4 1 1 4 4 2 1 2 3 4
output:
0 2 1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 116ms
memory: 3632kb
input:
117747 3 7 2 1 3 3 1 3 1 1 3 2 1 1 3 1 4 8 2 3 4 3 3 2 4 2 1 3 2 1 4 3 2 4 3 4 2 3 2 2 3 3 1 1 2 5 1 1 2 2 2 2 1 2 2 2 3 7 2 1 1 2 3 3 3 2 1 2 3 3 3 2 4 5 1 2 3 3 4 4 1 4 2 1 3 1 3 2 1 3 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 5 4 2 1 2 5 1 3 3 2 4 7 1 1 2 4 3 2 1 1 1 1 4 2 2 3 5 8 3 3 2 2 4 2 1 4 1...
output:
0 0 1 0 0 1 1 0 0 2 2 2 0 0 3 0 3 0 1 0 1 3 0 0 0 2 0 1 1 0 0 0 2 0 3 1 4 0 2 0 4 0 3 0 0 0 1 2 0 3 0 1 1 0 0 2 0 0 0 1 0 3 0 2 0 0 1 1 0 3 2 0 0 0 1 0 2 4 0 1 1 1 1 0 0 3 1 3 0 1 2 0 0 0 4 0 0 3 0 0 2 0 0 0 1 0 0 0 0 0 0 4 0 0 0 0 0 0 2 0 1 0 0 0 1 0 0 2 0 1 0 0 0 4 1 1 2 1 0 1 0 1 0 0 1 1 1 0 0 0 ...
result:
wrong answer 10th lines differ - expected: '1', found: '2'