贡献SPJ
查看原帖
贡献SPJ
64456
colazcy楼主2020/7/21 16:59
#include "testlib.h"
#include <string>
using namespace std;
const int maxn = 1e6 + 100;
namespace BIT{
	int f[maxn];
	inline int lowbit(int x){return x & (-x);}
	inline void add(int pos,int x){
		while(pos < maxn){
			f[pos] += x;
			pos += lowbit(pos);
		}
	}
	inline int query(int pos){
		int res = 0;
		while(pos){
			res += f[pos];
			pos -= lowbit(pos);
		}
		return res;
	}
	inline int query(int a,int b){return query(b) - query(a - 1);}
}
int n,k,pos[maxn];
string str;
int main(int argc,char *argv[]){
	registerTestlibCmd(argc, argv);
	n = inf.readInt();
	k = inf.readInt();
	inf.readEoln();
	str = inf.readLine();
	for(int qaq = 1;qaq <= n / (k + 1);qaq++){
		for(int i = 1;i <= k + 1;i++){
			pos[i] = ouf.readInt(1,n);
			if(BIT::query(pos[i],pos[i]))quitf(_wa,"TAT1");
		}
		int c = 0;
		for(int i = 1;i <= k + 1;i++)
			c += (str[pos[i] - 1] == 'c');
		if(c != 1)quitf(_wa,"TAT2",c);
		for(int i = 1;i <= k;i++)
			if(pos[i] >= pos[i + 1] || BIT::query(pos[i],pos[i + 1]))quitf(_wa,"TAT3");
		for(int i = 1;i <= k + 1;i++)BIT::add(pos[i],1);
	}
	quitf(_ok, "QAQ");
}

题面可添加说明:

返回TAT1:同一个位置输出22

返回TAT2:输出的k+1k+1个位置不满足白色是黑色kk

返回TAT3:未按照升序输出或者中间路过已经消除的砖

@kkksc03

2020/7/21 16:59
加载中...