前言
如果你在过 A 以后看榜发现有一众人 B 有 10 pts,那么可以试试传说中的 正确率大法,这样你会获得 rk20- 五分钟体验卡一张~
10pts
输出 -2 。致敬传奇总司令!
Sub3 显然都不合法。
注意到至少有两雨天,所以 时无解。
25pts
Sub5:只构造一种天气,以晴天举例,试图构造:
发现规律了吗?模 余 时以 为周期,余 时以 为周期。
另一种天气同理,用 代替即可。
if(x%3==0) fo(i,1,x) a[i]=(i%3==1?0:1);
else fo(i,1,x) a[i]=(i%3==0?0:1);100pts?
考虑怎么合并这两种天气,会发现由于最后一个天气必定要多出一个值导致另一种天气无法像从开头一样构造,似乎陷入僵局。。。
嗯?从开头构造?那么从右端同样可以啊!
于是你写出了如下代码:
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define fr(i,l,r) for(int i=l;i>=r;i--)
#define pb push_back
#define fi first
#define se second
#define par pair<int,int>
inline ll rd() {
ll x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
const int N=1e6+5;
int n,x,y,a[N];
signed main(){
int T=rd();
while(T--){
n=rd(),x=rd(),y=rd();
fo(i,1,n)a[i]=0;
if(x+y+2>n) {puts("-2");continue;}
if(x)
if(x%3==0) fo(i,1,x) a[i]=(i%3==1?0:1);
else fo(i,1,x) a[i]=(i%3==0?0:1);
if(y)
if(y%3==0) fo(i,1,y) a[n-i+1]=(i%3==1?0:-1);
else fo(i,1,y) a[n-i+1]=(i%3==0?0:-1);
fo(i,1,n)printf("%d ",a[i]);puts("");
}
return 0;
}但是 WA 80pts
那么问题出在哪里呢?让我们回头想想,会不会在一开始就早已误入歧途?
正解在下面,不过相信你肯定比我想得更快。
Accepted
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define fr(i,l,r) for(int i=l;i>=r;i--)
#define pb push_back
#define fi first
#define se second
#define par pair<int,int>
inline ll rd() {
ll x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
const int N=1e6+5;
int n,x,y,a[N];
signed main(){
int T=rd();
while(T--){
n=rd(),x=rd(),y=rd();
fo(i,1,n)a[i]=0;
if(x+y+2>n&&(x||y)) {puts("-2");continue;}//x=y=0,n=1
if(x)
if(x%3==0) fo(i,1,x) a[i]=(i%3==1?0:1);
else fo(i,1,x) a[i]=(i%3==0?0:1);
if(y)
if(y%3==0) fo(i,1,y) a[n-i+1]=(i%3==1?0:-1);
else fo(i,1,y) a[n-i+1]=(i%3==0?0:-1);
fo(i,1,n)printf("%d ",a[i]);puts("");
}
return 0;
}晴天,可不能起雾啊。