QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73742#4273. Good Game123456780 0ms3528kbC++141.8kb2023-01-27 20:59:412023-01-27 20:59:42

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-27 20:59:42]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3528kb
  • [2023-01-27 20:59:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define inf 1e9
#define pii pair <int, int>
const int mod = 1e9 + 7;
inline int read () {
	int x = 0, f = 1;
	char ch = getchar ();
	while (ch < '0' || ch > '9') f = ((ch == '-') ? -1 : f), ch = getchar ();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar ();
	return x * f;
}
inline void write (int x) {
	if (x < 0) x = -x, putchar ('-');
	if (x >= 10) write (x / 10);
	putchar (x % 10 + '0');
}
int n;
char ch[1000005];
int tot;
vector <pii> Ans, a;
int f[1000005][3], pre[1000005][3];
void print0(int fr, int x) {
	if(x & 1) Ans.push_back(mp(fr, 3)), x -= 3;
	while(x >= 2) Ans.push_back(mp(fr, 2)), x -= 2;
}
void print1(vector <pii> bas) {
	int mid = (int)bas.size() / 2, rk = 0;
	for(int i = 0; i < mid; i++) rk += bas[i].second;
	print0(rk + 1, bas[mid].second);
	for(int i = 1; i <= mid; i++) {
		rk -= bas[mid-i].second;
		print0(rk + 1, bas[mid-i].second + bas[mid+i].second);
	}
}
void print2(vector <pii> bas) {
	assert(0);
}
signed main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	n = read();
	scanf("%s", ch + 1);
	a.push_back(mp((ch[1] == 'A') ? 0 : 1, 1));
	for(int i = 2; i <= n; i++) {
		if(ch[i] != ch[i-1]) a.push_back(mp((ch[i] == 'A') ? 0 : 1, 1));
		else a.back().second++;
	}
	tot = (int)a.size();
	if(tot & 1) {
		if(a[tot/2].second >= 2) print1(a);
		else {
			int mx = 0, s = 0;
			for(auto x : a) {
				if(x.second < 2) s++;
				else s = 0;
				mx = max(mx, s);
			}
			if(mx < tot / 2) print2(a);
			else return printf("-1\n") & 0;
		}
	}
	else {
		
	}
	write((int)Ans.size()), putchar('\n');
	for(auto x : Ans) write(x.first), putchar(' '), write(x.second), putchar('\n');
	return 0;
}
/*
10
BBABBAABAB
*/

詳細信息

Subtask #1:

score: 0
Dangerous Syscalls

Test #1:

score: 3
Accepted
time: 0ms
memory: 3420kb

input:

9
ABAABBBAA

output:

4
3 2
2 2
2 2
1 3

result:

ok good solution!

Test #2:

score: -3
Dangerous Syscalls

input:

13
ABABBABABBABA

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 0ms
memory: 3528kb

input:

299
ABABABABABABABABABABABABABABABABABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

0

result:

wrong answer wrong solution (expected NO SOLUTION)

Subtask #3:

score: 0
Dangerous Syscalls

Test #102:

score: 0
Dangerous Syscalls

input:

5998
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:


result:


Subtask #4:

score: 0
Dangerous Syscalls

Test #153:

score: 0
Dangerous Syscalls

input:

999997
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:


result: