QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#780178#2432. Go with the FlowLJY_ljyWA 1ms3752kbC++111.2kb2024-11-25 06:59:282024-11-25 06:59:29

Judging History

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

  • [2024-11-25 06:59:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3752kb
  • [2024-11-25 06:59:28]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

const int MAXN = 100;
const int MAXM = 3000;
char str[MAXN];
int n, len[MAXM], minn, sum, eid, maxx, cnt[MAXN * MAXM], ans, ansx;
set<int> G[MAXM];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> str + 1;
		len[i] = strlen(str + 1);
		minn = max(minn, len[i]); 
		sum += len[i];
	}	
	for (int gap = minn; gap <= sum; gap++) {
		int maxx = 0;
		int j = 1, Len = 0, eid1 = 0;
		while (j <= n) {
			++eid1;
			while (Len + len[j] <= gap && j <= n) {
				Len = Len + len[j] + 1;
				if (Len + len[j + 1] <= gap && j < n) {
					G[eid1].insert(Len);
					int A = 0;
					if (G[eid1 - 1].count(Len - 1)) A = max(A, cnt[Len - 1]);
					if (G[eid1 - 1].count(Len)) A = max(A, cnt[Len]); 
					if (G[eid1 - 1].count(Len + 1)) A = max(A, cnt[Len + 1]);
					cnt[Len] = A + 1;
					maxx = max(maxx, cnt[Len]);
				}
				j++;
			}
			Len = 0;
		}
		for (int i = 1; i <= eid1; i++) {
			for (auto x:G[i]) {
				cnt[x] = 0;
			}
			G[i].clear();
		}
		if (maxx > ans) {
			ans = maxx;
			ansx = gap;
		}
	}
	cout << ansx << " " << ans << endl;
	return 0;
} 

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3752kb

Test #2:

score: 0
Accepted
time: 1ms
memory: 3692kb

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3712kb