QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#780185#2432. Go with the FlowLJY_ljyAC ✓2803ms4660kbC++111.4kb2024-11-25 07:22:092024-11-25 07:22:11

Judging History

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

  • [2024-11-25 07:22:11]
  • 评测
  • 测评结果:AC
  • 用时:2803ms
  • 内存:4660kb
  • [2024-11-25 07:22:09]
  • 提交

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, maxx, cnt[MAXN * MAXM], ans, ansx, aa[MAXM], bb[MAXM];
int G[MAXM]; 
bool used[MAXN * 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, eid = 0;
		int len1 = 0, len2 = 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[++eid] = Len;
					bb[++len2] = Len;
					int A = 0;
					if (used[Len - 1]) A = max(A, cnt[Len - 1]);
					if (used[Len]) A = max(A, cnt[Len]); 
					if (used[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 <= len1; i++) used[aa[i]] = false;
			for (int i = 1; i <= len2; i++) used[bb[i]] = true;
			len1 = len2;
			for (int i = 1; i <= len2; i++) aa[i] = bb[i];
			len2 = 0;
		}
		for (int i = 1; i <= len2; i++) used[i] = false;
		for (int i = 1; i <= eid; i++) cnt[G[i]] = 0;
		if (maxx > ans) {
			ans = maxx;
			ansx = gap;
		}
	}
	cout << ansx << " " << ans << endl;
	return 0;
} 

詳細信息

Test #1:

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

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

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

Test #13:

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

Test #14:

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

Test #15:

score: 0
Accepted
time: 57ms
memory: 3688kb

Test #16:

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

Test #17:

score: 0
Accepted
time: 513ms
memory: 3812kb

Test #18:

score: 0
Accepted
time: 523ms
memory: 3880kb

Test #19:

score: 0
Accepted
time: 180ms
memory: 3660kb

Test #20:

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

Test #21:

score: 0
Accepted
time: 1373ms
memory: 4248kb

Test #22:

score: 0
Accepted
time: 2803ms
memory: 4576kb

Test #23:

score: 0
Accepted
time: 52ms
memory: 3644kb

Test #24:

score: 0
Accepted
time: 110ms
memory: 3640kb

Test #25:

score: 0
Accepted
time: 828ms
memory: 4144kb

Test #26:

score: 0
Accepted
time: 842ms
memory: 4016kb

Test #27:

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

Test #28:

score: 0
Accepted
time: 210ms
memory: 3868kb

Test #29:

score: 0
Accepted
time: 215ms
memory: 3800kb

Test #30:

score: 0
Accepted
time: 206ms
memory: 3864kb

Test #31:

score: 0
Accepted
time: 2628ms
memory: 4536kb

Test #32:

score: 0
Accepted
time: 1273ms
memory: 4188kb

Test #33:

score: 0
Accepted
time: 1098ms
memory: 4116kb

Test #34:

score: 0
Accepted
time: 52ms
memory: 3700kb

Test #35:

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

Test #36:

score: 0
Accepted
time: 1304ms
memory: 4124kb

Test #37:

score: 0
Accepted
time: 2700ms
memory: 4512kb

Test #38:

score: 0
Accepted
time: 2641ms
memory: 4632kb

Test #39:

score: 0
Accepted
time: 2112ms
memory: 4364kb

Test #40:

score: 0
Accepted
time: 2312ms
memory: 4528kb

Test #41:

score: 0
Accepted
time: 2300ms
memory: 4484kb

Test #42:

score: 0
Accepted
time: 2681ms
memory: 4660kb

Test #43:

score: 0
Accepted
time: 2778ms
memory: 4596kb

Test #44:

score: 0
Accepted
time: 2752ms
memory: 4520kb

Test #45:

score: 0
Accepted
time: 2135ms
memory: 4360kb

Test #46:

score: 0
Accepted
time: 2053ms
memory: 4416kb

Test #47:

score: 0
Accepted
time: 2116ms
memory: 4408kb

Test #48:

score: 0
Accepted
time: 2084ms
memory: 4468kb

Test #49:

score: 0
Accepted
time: 2577ms
memory: 4492kb

Test #50:

score: 0
Accepted
time: 2345ms
memory: 4488kb

Test #51:

score: 0
Accepted
time: 2174ms
memory: 4496kb

Test #52:

score: 0
Accepted
time: 2136ms
memory: 4432kb

Test #53:

score: 0
Accepted
time: 1736ms
memory: 4308kb

Test #54:

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

Test #55:

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

Test #56:

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

Test #57:

score: 0
Accepted
time: 2654ms
memory: 4588kb

Test #58:

score: 0
Accepted
time: 2648ms
memory: 4656kb

Test #59:

score: 0
Accepted
time: 85ms
memory: 3880kb

Test #60:

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

Test #61:

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

Test #62:

score: 0
Accepted
time: 35ms
memory: 3744kb

Test #63:

score: 0
Accepted
time: 269ms
memory: 3916kb

Test #64:

score: 0
Accepted
time: 111ms
memory: 3828kb

Test #65:

score: 0
Accepted
time: 1871ms
memory: 4360kb

Test #66:

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