题解:CF1942C1 Bessie's Birthday Cake (Easy Version)
yaochenkai · · 题解
找能划分成几个三角形,题目的意思是从边入手,边构成了多少个三角形,而我们数边是通过数点来完成的,所以我们从点入手。
其实这个图形是几边形无所谓,只有
代码时间到!
#include<bits/stdc++.h>
using namespace std;
void solve() {
int n,x,y;
cin>>n>>x>>y;
vector<int>v(x);
for(int i=0;i<x;i++) cin>>v[i];
sort(v.begin(),v.end());
int ans=x;
for(int i=1;i<(int)v.size();i++)
if(v[i]==v[i-1]+2) ans++;
int a=v.size(),b=v[a-1]+2;
if(b>n) b-=n;
if(b==v[0]) ans++;
cout<<ans-2<<endl;
}
int main(){
int t;
cin>>t;
while(t--) solve();
return 0;
}
//各位大佬给个面子,点个赞吧