Codeforces Round #720 (Div. 2) 题解 (ABCD)

A. Nastia and nearly Good Numbers

#include <bits/stdc++.h>
#define repeat(i,a,b) for(int i=(a),ib=(b);i<ib;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,ib=(a);i>=ib;i--)
using namespace std;
typedef long long ll;
ll read(){ll x; if(scanf("%lld",&x)!=1)exit(0); return x;}
void print(ll x,bool e=0){printf("%lld%c",x," \n"[e]);}
const int N=200010;
void Solve(){
ll a=read(),b=read();
if(b==1)puts("NO");
else puts("YES"),print(a),print(a*b*b-a),print(a*b*b,1);
}
signed main(){
// freopen("data.txt","r",stdin);
int T=1; T=read();
repeat(ca,1,T+1){
Solve();
}
return 0;
}


B. Nastia and a Good Array

#include <bits/stdc++.h>
#define repeat(i,a,b) for(int i=(a),ib=(b);i<ib;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,ib=(a);i>=ib;i--)
using namespace std;
typedef long long ll;
ll read(){ll x; if(scanf("%lld",&x)!=1)exit(0); return x;}
void print(ll x,bool e=0){printf("%lld%c",x," \n"[e]);}
const int N=200010;
int a[N];
void Solve(){
int n=read();
repeat(i,0,n)a[i]=read();
int p=min_element(a,a+n)-a;
print(n-1,1);
repeat(i,0,n)if(i!=p){
if(i%2==p%2){
printf("%d %d %d %d\n",i+1,p+1,a[p],a[p]);
}
else{
printf("%d %d %d %d\n",i+1,p+1,a[p]+1,a[p]);
}
}
}
signed main(){
// freopen("data.txt","r",stdin);
int T=1; T=read();
repeat(ca,1,T+1){
Solve();
}
return 0;
}


C. Nastia and a Hidden Permutation

#include <bits/stdc++.h>
#define repeat(i,a,b) for(int i=(a),ib=(b);i<ib;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,ib=(a);i>=ib;i--)
using namespace std;
typedef long long ll;
ll read(){ll x; if(scanf("%lld",&x)!=1)exit(0); return x;}
void print(ll x,bool e=0){printf("%lld%c",x," \n"[e]);}
const int N=200010;
int query(int t,int i,int j,int x){
printf("? %d %d %d %d\n",t,i,j,x);
fflush(stdout);
return read();
}
int p,ans[N];
void find1(int x,int y){
int t=query(2,x,y,1);
if(t==1)p=x;
else if(t==2){
if(query(2,y,x,1)==1)
p=y;
}
}
void Solve(){
int n=read();
for(int i=1;i<=n;i+=2){
find1(i,i%n+1);
}
repeat(i,1,n+1)if(i!=p){
ans[i]=query(1,p,i,n-1);
}
ans[p]=1;
printf("!");
repeat(i,1,n+1)printf(" %d",ans[i]);
puts("");
fflush(stdout);
}
signed main(){
// freopen("data.txt","r",stdin);
int T=1; T=read();
repeat(ca,1,T+1){
Solve();
}
return 0;
}


D. Nastia Plays with a Tree

https://pasteme.cn/121793

posted @ 2021-05-08 01:05  axiomofchoice  阅读(184)  评论(0编辑  收藏  举报