# 1009

## 代码

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e5 + 5;
const int inf = ~0u >> 1;
typedef pair<int, int> P;
#define REP(i, a, n) for (int i = a; i < (n); ++i)
#define PER(i, a, n) for (int i = (n)-1; i >= a; --i)
const ll mod = 1e9 + 7;
int ans[maxn];
int main() {
IO;
int t;
cin >> t;
while (t--) {
int n, x, y;
cin >> n >> x >> y;
if (x == 1 || y == 1) {
if (x + y != n + 1) {
cout << "NO" << endl;
continue;
} else {
cout<<"YES"<<endl;
if (x == n) {
REP(i, 1, n + 1) {
if (i != 1) cout << ' ';
cout << i;
}
} else {
PER(i, 1, n + 1) {
if (i != n) cout << ' ';
cout << i;
}
}
cout << endl;
continue;
}
} else {
if (x + y - 1 > n) {
cout << "NO" << endl;
continue;
}
cout<<"YES"<<endl;
int sum = 0;
int num = n;
PER(i, 1, x + 1) {
int t = min(n - sum - (i - 1), y);
sum += t;
int tt = 1;
//cout << "t = " << t << endl;
PER(j, num - t + 1, num + 1) {
ans[n - sum + tt] = j;
//cout << "ans[" << n - sum + tt << "] = " << j << endl;
tt++;
}

num -= t;
}
REP(i, 1, n + 1) {
if (i != 1) cout << ' ';
cout << ans[i];
}
cout << endl;
}
}
return 0;

}


# 1010

## 思路

“图上随机游走”算法。建出无向图后，答案就是起点的度数+1，再除以总度数+n。

## 代码

#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false),cin.tie(0);
#define ll long long
#define inf 0x3f3f3f3f
const int N=1e5+5;
//set<string>b;
//set<string>::iterator it;
const int v[8][2]={0,1,0,-1,1,0,-1,0,1,1,-1,-1,-1,1,1,-1};
set<pair<ll,ll>>vis;
void fun(ll x,ll y)
{
int a1=0,a2=0,i,aa;
queue<pair<ll,ll>>q;
q.emplace(x,y);
vis.emplace(x,y);
while(q.size())
{
tie(x,y)=q.front();
q.pop();
if(x==y)
{
a1=0,a2=1;
break;
}
a2++;
for(i=0;i<8;i++)
{
ll dx=x+v[i][0];
ll dy=y+v[i][1];
if(__gcd(dx,dy)==1)
{
continue;
}
a2++;
if(vis.count(make_pair(dx,dy)))
{
continue;
}
vis.emplace(dx,dy);
q.emplace(dx,dy);
}
if(!a1) a1=a2;
}
aa=__gcd(a1,a2);
a1/=aa,a2/=aa;
printf("%d/%d\n",a1,a2);
}
int main()
{
int T;
ll x,y;
cin>>T;
while(T--)
{
scanf("%lld%lld",&x,&y);
fun(x,y);
}
return 0;
}



# 1007

## 代码


#include<bits/stdc++.h>
using namespace std;
long long x[2005],y[2005];
int vis[2005];
struct Node{
long long r;
int u,v;
}d[4000010];
bool cmp(Node a,Node b){
return a.r>b.r;
}
int main(){
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lld%lld",&x[i],&y[i]);
vis[i]=0;
}
int cnt=0;
for(int i=0;i<n;i++){
for(int j=0;j<i;j++){
d[cnt].r=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]y[j]);
d[cnt].u=i,d[cnt].v=j;
cnt++;
}
}
sort(d,d+cnt,cmp);
long long mx=-1;
int sum=n,flag=0;
for(int i=0;i<cnt;i++){
if(vis[d[i].u]||vis[d[i].v])continue;
set<int>s;
int j=i;
while(j<cnt&&d[j].r==d[i].r){
if(vis[d[j].u]||vis[d[j].v]){j++;continue;}
s.insert(d[j].u);
s.insert(d[j].v);
j++;
}
i=j-1;
for(auto v:s)vis[v]=1;
if(vis[0]==1&&sum>1)flag=1;
sum-=s.size();
}
printf(flag?"YES\n":"NO\n");
}
}



# 一级目录

## 代码

• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

For the brave

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

07-24 97
09-01 795
08-06 107
08-02 35