QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#606422 | #7332. Dissertation | Omar2718 | WA | 5ms | 4964kb | C++20 | 1.9kb | 2024-10-03 06:05:33 | 2024-10-03 06:05:33 |
Judging History
answer
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <climits>
#include <bits/stdc++.h>
#include <string>
#include <string.h>
#include <math.h>
#define msb(x) (31 - __builtin_clz(x))
#define int long long int
using namespace std;
void fileIO(void) {
#ifndef ONLINE_JUDGE
freopen("Input.txt", "r", stdin);
freopen("Output.txt", "w", stdout);
#endif
}
int dx[8] = {0,0,1,-1,1,-1,1,-1};
int dy[8] = {1,-1,0,0,1,-1,-1,1};
char pth[4] = {'L','R','U','D'};
int add(int a,int b,int mod){
return ((a % mod) + (b % mod) ) % mod;
}
int sub(int a,int b,int mod){
return ((a % mod) - (b % mod) + mod) % mod;
}
int multiply(int a,int b,int mod){
return ((a % mod) * (b % mod)) % mod;
}
bool equal(double a,double b){
return abs(a-b) <= 1e-7;
}
bool get_bit(int n , int i){
return n & (1ll << i);
}
void fastIO() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int gcd(int x,int y){
if(!min(x,y))
return max(x,y);
return gcd(max(x,y) % min(x,y), min(x,y));
}
int lcm(int x,int y){
return (x/gcd(x,y)) * y ;
}
int fact(int u){
if(u == 1)
return 1;
return u * fact(u-1);
}
int can(int x,int y){
return x >= 0 && x < 3 && y >= 0 && y <3;
}
string a,b;
//abcd
//bcda
map<pair<int,int>,int>dp;
map<pair<int,int>,bool>vis;
int f(int i,int curr){
int ch1=0,ch2=0,ch3=0;
if(i == a.size() || curr == b.size())
return 0;
if(vis[{i,curr}])
return dp[{i,curr}];
vis[{i,curr}] = true;
ch1 = f(i+1,curr);
ch2 = f(i,curr+1);
if(a[i] == b[curr])
ch3 = 1 + f(i+1,curr+1);
return dp[{i,curr}] = max({ch1,ch2,ch3});
}
void solve() {
cin >> a >> b;
cout << f(0,0) << '\n';
}
signed main() {
fastIO();
fileIO();
int t;cin>>t;
while (t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
1 abcdefghijklmnopqrstuvwxyz bbddee
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 4964kb
input:
4106 ababbbab babaa aabaaaaa bbbab aababaab bbaab aababbba aaaaa aabbabbb baabb aabababb abbbb aabbabab babaa aaabbaaa aaabb aaababba ababb aabbbaba abaaa abbbaaba bbbab aaaababb aabab abbbaaba abbba abbbabbb bbbaa aaabaaaa aaabb abbababb baaaa aaaababb babbb abaaaaab aabaa ababaaab aabaa abbbabaa b...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...
result:
wrong answer 2nd numbers differ - expected: '2', found: '4'