QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#846285#9988. 挑战大模型CrysflyAC ✓1878ms479872kbC++142.0kb2025-01-07 02:43:002025-01-07 02:43:01

Judging History

你现在查看的是测评时间为 2025-01-07 02:43:01 的历史记录

  • [2025-01-07 02:48:40]
  • 管理员手动重测该提交记录
  • 测评结果:AC
  • 用时:2861ms
  • 内存:510228kb
  • [2025-01-07 02:46:35]
  • 管理员手动重测该提交记录
  • 测评结果:0
  • 用时:2829ms
  • 内存:511300kb
  • [2025-01-07 02:43:01]
  • 评测
  • 测评结果:0
  • 用时:1878ms
  • 内存:479872kb
  • [2025-01-07 02:43:00]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,x,y) for (int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (int i=(x);i<(y);i++)
#define Dow(i,x,y) for (int i=(x);i>=(y);i--)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define fil(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
	ll x=0,f=1;char c=getchar();
	while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if (c=='-') f=-1,c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}

const int N = 510;
int n,m,ans[N],a[N],l[N],r[N],top,stk[N];
char s1[N][N],s2[N][N];
short lcp[N][N][N],mn[N][N][N];

inline bool check(int lx,int rx,int ly,int ry){
	if (lx>rx||ly>ry) return 1;
	if (ly+mn[ly][lx][rx]-1>=ry) return 1;
	return 0;
}

int main(){
	n=read(),m=read();
	For(i,1,n) scanf("%s",s1[i]+1);
	For(i,1,n) scanf("%s",s2[i]+1);
	For(i,1,n){
		Dow(j,m,1) Dow(k,m,1){
			if (s1[i][j]==s2[i][k]) lcp[i][j][k]=lcp[i][j+1][k+1]+1;
		}
	}
	For(j,1,m){
		For(l,1,n){
			mn[j][l][l]=lcp[l][j][j];
			For(r,l+1,n){
				mn[j][l][r]=min(mn[j][l][r-1],lcp[r][j][j]);
			}
		}
	} 
	For(i,1,m-1) ans[i]=-1;
	For(j,1,m) For(k,j+1,m){
		For(i,1,n) a[i]=lcp[i][k][j];
		//For(i,1,n) printf("%d ",a[i]);
		//puts("");
		top=0;
		stk[0]=0;
		For(i,1,n){
			while (top&&a[i]<=a[stk[top]]) --top;
			l[i]=stk[top]+1;
			stk[++top]=i;
		}
		top=0;
		stk[0]=n+1;
		Dow(i,n,1){
			while (top&&a[i]<=a[stk[top]]) --top;
			r[i]=stk[top]-1;
			stk[++top]=i;
		}
		For(i,1,n){
			int L=l[i],R=r[i];
			if (!check(1,L-1,1,m)) continue;
			if (!check(R+1,n,1,m)) continue;
			if (!check(L,R,1,j-1)) continue;
			if (!check(L,R,k+a[i],m)) continue;
			if (!check(L,R,j+a[i],k-1)) continue;
			if (a[i]==0) continue;
			ans[k-j]=max(ans[k-j],(R-L+1)*a[i]);
		}
	}
	For(i,1,m-1) printf("%d ",ans[i]);
}

详细

Test #1:

score: 0
Wrong Answer
time: 1878ms
memory: 479872kb

input:

484 484
1001110011010001101100110111010110011011110110101001010000101111010111001100111011010010000011110111011101000101000011011011100111001111111100100101101000111000100000011100110011101000101000010100101010011110000111101101100110000110111100100001111001110111010001000111101001111111001000001001...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer 1st lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 '