Submission #690257

# Submission time Handle Problem Language Result Execution time Memory
690257 2023-01-30T05:27:53 Z moonhero Round words (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 = 1; i <= a.size(); i++) {
        for (int j = 1; 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 = 1; 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 = 1; 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++) {
      |                         ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Incorrect 1 ms 468 KB Output isn't correct
6 Correct 2 ms 4692 KB Output is correct
7 Correct 8 ms 8148 KB Output is correct
8 Incorrect 8 ms 8148 KB Output isn't correct
9 Incorrect 8 ms 8148 KB Output isn't correct
10 Incorrect 9 ms 8136 KB Output isn't correct
11 Incorrect 9 ms 8916 KB Output isn't correct
12 Correct 11 ms 9668 KB Output is correct
13 Incorrect 10 ms 9672 KB Output isn't correct
14 Incorrect 9 ms 9156 KB Output isn't correct
15 Incorrect 10 ms 9924 KB Output isn't correct
16 Incorrect 8 ms 8788 KB Output isn't correct
17 Incorrect 7 ms 9276 KB Output isn't correct
18 Incorrect 10 ms 11444 KB Output isn't correct
19 Incorrect 8 ms 8148 KB Output isn't correct
20 Incorrect 9 ms 10188 KB Output isn't correct
21 Incorrect 5 ms 8132 KB Output isn't correct
22 Incorrect 6 ms 9316 KB Output isn't correct
23 Incorrect 7 ms 10024 KB Output isn't correct
24 Incorrect 8 ms 10444 KB Output isn't correct
25 Incorrect 11 ms 11860 KB Output isn't correct