社区讨论
15pts悬2关求hack
P13713 晴天参与者 4已保存回复 8
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 8 条
- 当前快照
- 1 份
- 快照标识符
- @mhjhhl26
- 此快照首次捕获于
- 2025/11/04 02:39 4 个月前
- 此快照最后确认于
- 2025/11/04 02:39 4 个月前
思路:先构造前面x+1个1,使得最后一位一定为0,在输出0,构造后面y-1个,在最后把剩余的全部补成雨天
code:
CPP#include <bits/stdc++.h>
using namespace std;
signed main(){
//freopen("w1.in","r",stdin);
//freopen("w2.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t;
cin>>t;
//cout<<t<<'\n';
while(t--){
int n,x,y;
cin>>n>>x>>y;
//cout<<n<<" "<<x<<" "<<y<<'\n';
if(n==1 && x==0 && y==0){
cout<<0<<'\n';
continue;
}
if(x+y+2>n){
cout<<-2<<'\n';
continue;
}
for(int i=1;i<=x+1;i++){
if(i%2==(x)%2)cout<<1<<" ";
else cout<<0<<" ";
}
cout<<0<<" ";
for(int i=1;i<y;i++){
if(i%2==1)cout<<-1<<" ";
else cout<<0<<" ";
}
if(y==0){
for(int i=x+y+3;i<=n;i++)cout<<0<<" ";
}else if((y+1)%2==1){
cout<<0<<" ";
for(int i=x+y+3,j=1;i<=n;i++,j++){
if(j%3==1)cout<<1<<" ";
else if(j%3==2)cout<<-1<<" ";
else cout<<0<<" ";
}
}else {
cout<<-1<<" ";
for(int i=x+y+3,j=1;i<=n;i++,j++){
if(j%3==1)cout<<1<<" ";
else if(j%3==2)cout<<-1<<" ";
else cout<<0<<" ";
}
}
cout<<'\n';
}
return 0;
}
record:https://www.luogu.com.cn/record/230784265
回复
共 8 条回复,欢迎继续交流。
正在加载回复...