답안 #690272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
690272 2023-01-30T05:34:23 Z moonhero 원형 문자열 (IZhO13_rowords) C++17
28 / 100
11 ms 11860 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e3 + 5;
int dp[N][N];
int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string a, b; cin >> a >> b;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    for (int i = 0; i <= a.size(); i++) {
        for (int j = 0; j <= b.size(); j++) {
            dp[i][j] = 0;
        }
    } for (int i = 1; i <= a.size(); i++) {
        for (int j = 1; j <= b.size(); j++) {
            if (a[i - 1] == b[j - 1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } dp[i][j] = max({dp[i][j - 1], dp[i - 1][j], dp[i][j]});
        }
    } cout << dp[a.size()][b.size()];
    return 0;
}

Compilation message

rowords.cpp: In function 'int main()':
rowords.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i <= a.size(); i++) {
      |                     ~~^~~~~~~~~~~
rowords.cpp:13:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for (int j = 0; j <= b.size(); j++) {
      |                         ~~^~~~~~~~~~~
rowords.cpp:16:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     } for (int i = 1; i <= a.size(); i++) {
      |                       ~~^~~~~~~~~~~
rowords.cpp:17:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int j = 1; j <= b.size(); j++) {
      |                         ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Incorrect 1 ms 484 KB Output isn't correct
6 Correct 3 ms 4692 KB Output is correct
7 Correct 8 ms 8148 KB Output is correct
8 Incorrect 9 ms 8172 KB Output isn't correct
9 Incorrect 8 ms 8180 KB Output isn't correct
10 Incorrect 8 ms 8148 KB Output isn't correct
11 Incorrect 10 ms 8916 KB Output isn't correct
12 Correct 10 ms 9684 KB Output is correct
13 Incorrect 10 ms 9684 KB Output isn't correct
14 Incorrect 9 ms 9172 KB Output isn't correct
15 Incorrect 11 ms 9940 KB Output isn't correct
16 Incorrect 9 ms 8788 KB Output isn't correct
17 Incorrect 8 ms 9384 KB Output isn't correct
18 Incorrect 11 ms 11348 KB Output isn't correct
19 Incorrect 8 ms 8148 KB Output isn't correct
20 Incorrect 10 ms 10256 KB Output isn't correct
21 Incorrect 4 ms 8148 KB Output isn't correct
22 Incorrect 6 ms 9300 KB Output isn't correct
23 Incorrect 7 ms 9940 KB Output isn't correct
24 Incorrect 7 ms 10452 KB Output isn't correct
25 Incorrect 9 ms 11860 KB Output isn't correct