本题 Special Judge
查看原帖
本题 Special Judge
28910
览遍千秋七海楼主2022/12/24 16:20
//Special Judge for USACO22DEC Bronze Pro1
//By Expect2004 
#include "testlib.h"
using namespace std;

int n, k;
int cH[100007], cG[100007];

int main(int argc, char *argv[]) {
	registerTestlibCmd(argc, argv);
	int T = inf.readInt();
	for(int cas = 1; cas <= T; cas++) {
		int CowsAns = ans.readInt(), CowsUser = ouf.readInt();
		if(CowsAns != CowsUser) {
			quitf(_wa, "The number of minimum grass for Case %d is incorrect. Read %d, Expected %d.", cas, CowsUser, CowsAns);
		}
		ans.readEoln(); ouf.readEoln();
		string Gans = ans.readString();
		string Guser = ouf.readString();
		int len = Guser.size();
		if(len != (int)Gans.size()) {
			quitf(_wa, "length of output for Case %d is not equal to n", cas);
		}
		int cnt = 0;
		for(int i = 0; i < len; i++) {
			if(Guser[i] != '.' && Guser[i] != 'G' && Guser[i] != 'H') {
				quitf(_wa, "In Case %d, Invaild character", cas);
			}
			if(Guser[i] != '.') ++cnt;
		}
		if(cnt != CowsAns) {
			quitf(_wa, "In Case %d, the number of character G and H is not equal to what you have calculated", cas);
		}
		for(int i = 0; i <= n; i++) cH[i] = cG[i] = 0;
		n = inf.readInt();
		k = inf.readInt();
		inf.readEoln();
		string Cows = inf.readString();
		for(int i = 0; i < len; i++) {
			if(Guser[i] == '.') continue;
			if(Guser[i] == 'H') {
				int lbound = i - k, rbound = i + k;
				lbound = max(0, lbound), rbound = min(rbound, n - 1);
				cH[lbound]++, cH[rbound + 1]--;
			}
			else {
				int lbound = i - k, rbound = i + k;
				lbound = max(0, lbound), rbound = min(rbound, n - 1);
				cG[lbound]++, cG[rbound + 1]--;
			}
		}
		for(int i = 1; i < n; i++) cH[i] += cH[i - 1], cG[i] += cG[i - 1];
		for(int i = 0; i < len; i++) {
			if(Cows[i] == 'G') {
				if(cG[i] <= 0) {
					quitf(_wa, "In Case %d, the cow with position %d do not have grass to eat", cas, i + 1);
				}
			}
			else {
				if(cH[i] <= 0) {
					quitf(_wa, "In Case %d, the cow with position %d do not have grass to eat", cas, i + 1);
				}
			}
		}
	}
	quitf(_ok, "Accepted");
	return 0;
}

欢迎找错()

2022/12/24 16:20
加载中...