QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780184#2432. Go with the FlowLJY_ljyTL 11505ms4044kbC++111.2kb2024-11-25 07:12:222024-11-25 07:12:22

Judging History

This is the latest submission verdict.

  • [2024-11-25 07:12:22]
  • Judged
  • Verdict: TL
  • Time: 11505ms
  • Memory: 4044kb
  • [2024-11-25 07:12:22]
  • Submitted

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: 3756kb

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

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

Test #13:

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

Test #14:

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

Test #15:

score: 0
Accepted
time: 887ms
memory: 3840kb

Test #16:

score: 0
Accepted
time: 11505ms
memory: 3972kb

Test #17:

score: 0
Accepted
time: 11078ms
memory: 3976kb

Test #18:

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

Test #19:

score: 0
Accepted
time: 3024ms
memory: 4008kb

Test #20:

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

Test #21:

score: -100
Time Limit Exceeded