Submission #523250

# Submission time Handle Problem Language Result Execution time Memory
523250 2022-02-07T09:19:35 Z levsog2004 Round words (IZhO13_rowords) C++14
0 / 100
38 ms 32352 KB
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;

#define ll long long int 
#define forr(n) for(ll i=0;i<n;i++) 
#define um unordered_map<int,int>  
#define vec vector<int> 
#define vecl vector<ll> 
#define pb push_back 
#define bg begin()
#define en end()


void solve() {

    string s, t;
    cin >> s >> t;
    int tt = s.size();
    for (int i = 0; i < tt; ++i)
    {
        s.push_back(s[i]);
    }
    tt = t.size();
    for (int i = 0; i < tt; ++i)
    {
        t.push_back(t[i]);
    }
    int dp[2005][2005];
    int ss = s.size(); tt = t.size();

    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= ss; i++) {
        for (int j = 1; j <= tt; j++) {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string ans;
    int i = ss, j = tt;
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1])
        {
            ans += s[i - 1];
            i--; j--;
        }
        else {
            if (dp[i - 1][j] > dp[i][j - 1])
                i--;
            else
                j--;
        }
    }
    reverse(ans.bg, ans.en);
    cout << ans << " ";








}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 15948 KB Output isn't correct
2 Incorrect 8 ms 15936 KB Output isn't correct
3 Incorrect 9 ms 15948 KB Output isn't correct
4 Incorrect 12 ms 15948 KB Output isn't correct
5 Incorrect 11 ms 15948 KB Output isn't correct
6 Incorrect 11 ms 16012 KB Output isn't correct
7 Incorrect 27 ms 15948 KB Output isn't correct
8 Incorrect 14 ms 16036 KB Output isn't correct
9 Incorrect 17 ms 16036 KB Output isn't correct
10 Incorrect 17 ms 15948 KB Output isn't correct
11 Runtime error 31 ms 32288 KB Execution killed with signal 11
12 Runtime error 26 ms 32252 KB Execution killed with signal 11
13 Runtime error 34 ms 32324 KB Execution killed with signal 11
14 Runtime error 38 ms 32324 KB Execution killed with signal 11
15 Runtime error 37 ms 32300 KB Execution killed with signal 11
16 Runtime error 29 ms 32244 KB Execution killed with signal 11
17 Runtime error 35 ms 32316 KB Execution killed with signal 11
18 Runtime error 33 ms 32324 KB Execution killed with signal 11
19 Incorrect 24 ms 16044 KB Output isn't correct
20 Runtime error 32 ms 32308 KB Execution killed with signal 11
21 Runtime error 30 ms 32352 KB Execution killed with signal 11
22 Runtime error 28 ms 32304 KB Execution killed with signal 11
23 Runtime error 30 ms 32332 KB Execution killed with signal 11
24 Runtime error 26 ms 32340 KB Execution killed with signal 11
25 Runtime error 27 ms 32308 KB Execution killed with signal 11