답안 #47539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47539 2018-05-05T03:02:36 Z ngkan146 원형 문자열 (IZhO13_rowords) C++11
12 / 100
60 ms 32888 KB
#include <bits/stdc++.h>
using namespace std;
string t[2], s[2];
int dp[4005][4005];
int main(){
    cin >> s[0] >> s[1];
    s[0] = '0' + s[0];
    s[1] = '0' + s[1];
    for(int i=1;i<s[0].size();i++){
        for(int j=1;j<s[1].size();j++){
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[0][i] == s[1][j])
                dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
        }
    }
    int tmp = dp[s[0].size()-1][s[1].size()-1];
    s[0].erase(s[0].begin());
    s[1].erase(s[1].begin());
    s[0] = '0' + s[0];
    s[1] = '0' + s[1];
    s[0] += s[0];
    s[1] += s[1];
    //cerr << s[0] << '\n' << s[1] << '\n';
    for(int i=1;i<s[0].size();i++){
        for(int j=1;j<s[1].size();j++){
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[0][i] == s[1][j])
                dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
        }
    }
    cout << dp[s[0].size()-1][s[1].size()-1] - tmp;
}

Compilation message

rowords.cpp: In function 'int main()':
rowords.cpp:9:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<s[0].size();i++){
                 ~^~~~~~~~~~~~
rowords.cpp:10:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=1;j<s[1].size();j++){
                     ~^~~~~~~~~~~~
rowords.cpp:24:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<s[0].size();i++){
                 ~^~~~~~~~~~~~
rowords.cpp:25:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=1;j<s[1].size();j++){
                     ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 3 ms 504 KB Output isn't correct
4 Incorrect 3 ms 760 KB Output isn't correct
5 Correct 3 ms 632 KB Output is correct
6 Incorrect 16 ms 9976 KB Output isn't correct
7 Incorrect 40 ms 24056 KB Output isn't correct
8 Incorrect 42 ms 23968 KB Output isn't correct
9 Incorrect 40 ms 24056 KB Output isn't correct
10 Incorrect 40 ms 24056 KB Output isn't correct
11 Incorrect 47 ms 26360 KB Output isn't correct
12 Incorrect 60 ms 30076 KB Output isn't correct
13 Incorrect 50 ms 30072 KB Output isn't correct
14 Incorrect 45 ms 27512 KB Output isn't correct
15 Incorrect 52 ms 31736 KB Output isn't correct
16 Incorrect 45 ms 26232 KB Output isn't correct
17 Incorrect 43 ms 24952 KB Output isn't correct
18 Correct 53 ms 32888 KB Output is correct
19 Incorrect 39 ms 24056 KB Output isn't correct
20 Incorrect 52 ms 29304 KB Output isn't correct
21 Incorrect 25 ms 18040 KB Output isn't correct
22 Incorrect 32 ms 21880 KB Output isn't correct
23 Correct 37 ms 24696 KB Output is correct
24 Incorrect 40 ms 26104 KB Output isn't correct
25 Incorrect 51 ms 30584 KB Output isn't correct