QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#741147 | #7990. 广播 | _LSA_# | WA | 0ms | 20856kb | C++14 | 1.1kb | 2024-11-13 13:34:45 | 2024-11-13 13:34:45 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
using namespace std;
ll read(){
ll X = 0 ,r = 1;
char ch = getchar();
while(!isdigit(ch) && ch != '-') ch = getchar();
if(ch == '-') r = -1,ch = getchar();
while(isdigit(ch)) X = X*10+ch-'0',ch = getchar();
return X*r;
}
const int N = 2100;
int n,m;
int a[N],b[N];
int f[N][N];
int main(){
n = read(); m = read();
for(int i=1;i<=n;i++) a[i] = read();
for(int i=1;i<=m;i++) b[i] = read();
reverse(a+1,a+1+n);
reverse(b+1,b+1+m);
int ans = 1e9;
memset(f,0x3f,sizeof(f));
f[0][0] = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
f[i][j] = min(f[i][j],f[i-1][j]+1);
f[i][j] = min(f[i][j],f[i][j-1]+1);
if(a[i] == b[j] || a[i] == 1 || b[j] == 1) f[i][j] = min(f[i][j],f[i-1][j-1]);
if(i == n || j == m) ans = min(ans,f[i][j]);
}
}
cout << ans;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 20848kb
input:
4 2 2 1 3 2 4 2
output:
1
result:
ok single line: '1'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 20856kb
input:
1 1 2 3
output:
1000000000
result:
wrong answer 1st lines differ - expected: '1', found: '1000000000'