QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#707783 | #7051. Largest Common Submatrix | Loxilante | WA | 0ms | 13844kb | C++20 | 1.8kb | 2024-11-03 17:30:55 | 2024-11-03 17:30:56 |
Judging History
answer
#define F_C
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#endif
const int U = 1.5e3;
int w[U][U], c[U][U], l[U][U], r[U][U], u[U][U], t[U*U];
signed main(void)
{
#ifdef LOCAL
// freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
// freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin>>n>>m;
rep(i, 0, n) rep(j, 0, m) t[next()] = i*m+j+1;
rep(i, 0, n) rep(j, 0, m) cin>>w[i][j], l[i][j] = r[i][j] = j, u[i][j] = 1;
rep(i, 0, n) rep(j, 0, m) w[i][j] = t[w[i][j]];
int col = 0;
rep(i, 0, n) rep(j, 0, m)
{
if (i && w[i][j] == w[i-1][j]+m) c[i][j] = c[i-1][j];
else if (j && w[i][j] == w[i][j-1]+1) c[i][j] = c[i][j-1];
else c[i][j] = ++col;
}
rep(i, 0, n) rep(j, 1, m) if (c[i][j] == c[i][j-1]) l[i][j] = l[i][j-1];
rep(i, 0, n) rev(j, m-2, 0) if (c[i][j] == c[i][j+1]) r[i][j] = r[i][j+1];
int ans = 0;
rep(i, 0, n) rep(j, 0, m)
{
if (i && c[i][j] == c[i-1][j])
{
l[i][j] = max(l[i][j], l[i-1][j]);
r[i][j] = min(r[i][j], r[i-1][j]);
u[i][j] = u[i-1][j]+1;
}
ans = max(ans, (r[i][j]-l[i][j]+1)*u[i][j]);
}
cout<<ans<<endl;
// rep(i, 0, n) rep(j, 0, m) cout<<w[i][j]<<" \n"[j == m-1];
rep(i, 0, n) rep(j, 0, m) cout<<c[i][j]<<" \n"[j == m-1];
return 0;
}
/*
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 13844kb
input:
3 4 5 6 7 8 1 2 3 4 9 10 11 12 5 6 8 7 1 2 4 3 12 11 10 9
output:
4 1 1 2 3 1 1 2 3 4 5 6 7
result:
wrong answer Output contains longer sequence [length = 13], but answer contains 1 elements