QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780180#2432. Go with the FlowLJY_ljyTL 11390ms4044kbC++111.2kb2024-11-25 07:03:152024-11-25 07:03:17

Judging History

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

  • [2024-11-25 07:03:17]
  • 评测
  • 测评结果:TL
  • 用时:11390ms
  • 内存:4044kb
  • [2024-11-25 07:03:15]
  • 提交

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 + MAXM; 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;
} 

Details

Test #1:

score: 100
Accepted
time: 2ms
memory: 3836kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 0ms
memory: 3684kb

Test #4:

score: 0
Accepted
time: 4ms
memory: 3824kb

Test #5:

score: 0
Accepted
time: 33ms
memory: 3788kb

Test #6:

score: 0
Accepted
time: 8ms
memory: 3844kb

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

score: 0
Accepted
time: 4ms
memory: 3716kb

Test #12:

score: 0
Accepted
time: 9ms
memory: 3684kb

Test #13:

score: 0
Accepted
time: 849ms
memory: 3920kb

Test #14:

score: 0
Accepted
time: 859ms
memory: 3844kb

Test #15:

score: 0
Accepted
time: 865ms
memory: 3824kb

Test #16:

score: 0
Accepted
time: 11390ms
memory: 3964kb

Test #17:

score: 0
Accepted
time: 11079ms
memory: 4044kb

Test #18:

score: 0
Accepted
time: 10998ms
memory: 4032kb

Test #19:

score: 0
Accepted
time: 2958ms
memory: 3908kb

Test #20:

score: 0
Accepted
time: 1936ms
memory: 3904kb

Test #21:

score: -100
Time Limit Exceeded