CSES - E4590 2016 1 - Results
Submission details
Task:Edit distance
Sender:Ollie
Submission time:2016-09-17 15:08:12 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1UNKNOWN--details
#2UNKNOWN--details
#3UNKNOWN--details
#4UNKNOWN--details
#5UNKNOWN--details
#6UNKNOWN--details
#7UNKNOWN--details
#8UNKNOWN--details
#9UNKNOWN--details
#10UNKNOWN--details
#11UNKNOWN--details
#12UNKNOWN--details
#13UNKNOWN--details
#14UNKNOWN--details
#15UNKNOWN--details
#16UNKNOWN--details
#17UNKNOWN--details
#18UNKNOWN--details
#19UNKNOWN--details

Compiler report

input/code.cpp: In function 'void print()':
input/code.cpp:16:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<=a.length();i++) {
                           ^
input/code.cpp:17:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<=b.length();j++) {
                             ^
input/code.cpp: In function 'int main()':
input/code.cpp:29:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1;i<=a.length();i++) {
                           ^
input/code.cpp:30:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=1;j<=b.length();j++) {
                             ^

Code

#include <bits/stdc++.h>

#define _ ios_base::sync_with_stdio(0);cin.tie();
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define vpii vector<pii>

using namespace std;

int dp[5001][5001];
string a, b;

void print() {
  for(int i=0;i<=a.length();i++) {
    for(int j=0;j<=b.length();j++) {
      cout << dp[i][j] << " ";
    } cout << endl;
  }
}

int main() { _
  cin >> a >> b;
  for(int i=0;i<=5000;i++) {
    dp[i][0] = dp[0][i] = i;
  }
  dp[0][0] = 0;
  for(int i=1;i<=a.length();i++) {
    for(int j=1;j<=b.length();j++) {
      int o1 = dp[i-1][j]+1;
      int o2 = dp[i][j-1]+1;
      int o3 = dp[i-1][j-1]+(a[i-1]==b[j-1]?0:1);
      dp[i][j] = min(o1, min(o2, o3));
    }
  }
  cout << dp[a.length()][b.length()] << endl;
  return 0;
}

Test details

Test 1

Verdict: UNKNOWN

input
NEABJPJOI
RFMQRJKJKIA

correct output
8

user output
(not available)

Test 2

Verdict: UNKNOWN

input
TWXFUABGBNLTBFNSUVQW
GPNJILFXJUIZPLTVUIB

correct output
19

user output
(not available)

Test 3

Verdict: UNKNOWN

input
HSMOWJXKGRWSMD
JMRTLLNPXKKXZC

correct output
14

user output
(not available)

Test 4

Verdict: UNKNOWN

input
NGPYCNPO
UQPXWVLGHC

correct output
9

user output
(not available)

Test 5

Verdict: UNKNOWN

input
SQTCKWAMFJEBV
IUWGGNJOMQFP

correct output
13

user output
(not available)

Test 6

Verdict: UNKNOWN

input
VDREWLLHMEVGFGBXJJOSSLHNJBOTRK...

correct output
4047

user output
(not available)

Test 7

Verdict: UNKNOWN

input
EIIUUQXSAFMTRSEZSFYNSAGHUWTSGY...

correct output
3769

user output
(not available)

Test 8

Verdict: UNKNOWN

input
HVOXUVAZYFBKEWQXVGJMYXCCXBWRNW...

correct output
3806

user output
(not available)

Test 9

Verdict: UNKNOWN

input
AWGASQANDZQTVKXQDKWNADQDBXKCOK...

correct output
4069

user output
(not available)

Test 10

Verdict: UNKNOWN

input
WXAAJJALZRLGLSXDPUPURULYINBFGX...

correct output
3874

user output
(not available)

Test 11

Verdict: UNKNOWN

input
A
A

correct output
0

user output
(not available)

Test 12

Verdict: UNKNOWN

input
A
B

correct output
1

user output
(not available)

Test 13

Verdict: UNKNOWN

input
AA
A

correct output
1

user output
(not available)

Test 14

Verdict: UNKNOWN

input
A
AA

correct output
1

user output
(not available)

Test 15

Verdict: UNKNOWN

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
5000

user output
(not available)

Test 16

Verdict: UNKNOWN

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
0

user output
(not available)

Test 17

Verdict: UNKNOWN

input
B
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
5000

user output
(not available)

Test 18

Verdict: UNKNOWN

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
5000

user output
(not available)

Test 19

Verdict: UNKNOWN

input
KITTEN
SITTING

correct output
3

user output
(not available)