Submission #1813325
Source Code Expand
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<map> #include<set> #include<algorithm> #include<numeric> #define rep(n) for(int i=0;i<n;i++) #define repp(j, n) for(int j=0;j<n;j++) #define reppp(i, m, n) for(int i=m;i<=n;i++) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define pb(x) push_back(x) #define eb(x,y) emplace_back(x,y) #define MOD 1000000007 #define MAX 1000000001 #define INF 1410065408 #define EPS 1e-9 #define DEBUG 0 #define ll long long #define Pll pair<ll, ll> #define Pii pair<int, int> using namespace std; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int H, W; cin >> H >> W; vector<string> c(H); rep(H) cin >> c[i]; int ans = 0; repp(k, W-1){ int dp[H+1][H+1]; fill(dp[0], dp[H+1], INF); dp[0][0] = 0; repp(i, H+1){ repp(j, H+1){ if(i == H+1 && j == H+1) break; int cost = 0; int ii = i, jj = j; int base = min(i, j); while(ii < H && jj < H){ if(c[jj-base][k] == c[ii-base][k+1]){ cost++; } ii++; jj++; } // cout << i << " " << j << " " << cost << endl; dp[i+1][j] = min(dp[i+1][j], dp[i][j] + cost); dp[i][j+1] = min(dp[i][j+1], dp[i][j] + cost); } } // cout << dp[H][H] << endl; ans += dp[H][H]; } cout << ans; }
Submission Info
Submission Time | |
---|---|
Task | D - Friction |
User | Noimin |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1735 Byte |
Status | RE |
Exec Time | 123 ms |
Memory | 768 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | 0 / 500 | ||||||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt |
Subtask | 0_000.txt, 0_001.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt, 2_030.txt, 2_031.txt, 2_032.txt, 2_033.txt, 2_034.txt, 2_035.txt, 2_036.txt, 2_037.txt, 2_038.txt, 2_039.txt, 2_040.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | WA | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
0_003.txt | AC | 1 ms | 256 KB |
0_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 1 ms | 256 KB |
1_006.txt | RE | 123 ms | 640 KB |
1_007.txt | RE | 123 ms | 640 KB |
1_008.txt | RE | 123 ms | 640 KB |
1_009.txt | RE | 122 ms | 640 KB |
1_010.txt | RE | 123 ms | 640 KB |
1_011.txt | AC | 44 ms | 640 KB |
1_012.txt | AC | 51 ms | 640 KB |
1_013.txt | RE | 106 ms | 384 KB |
1_014.txt | RE | 123 ms | 640 KB |
1_015.txt | RE | 105 ms | 384 KB |
1_016.txt | RE | 122 ms | 640 KB |
1_017.txt | RE | 96 ms | 256 KB |
1_018.txt | RE | 122 ms | 640 KB |
1_019.txt | RE | 102 ms | 384 KB |
1_020.txt | RE | 122 ms | 640 KB |
1_021.txt | RE | 120 ms | 640 KB |
1_022.txt | RE | 122 ms | 640 KB |
2_023.txt | AC | 1 ms | 256 KB |
2_024.txt | RE | 123 ms | 768 KB |
2_025.txt | RE | 122 ms | 768 KB |
2_026.txt | RE | 121 ms | 768 KB |
2_027.txt | RE | 122 ms | 768 KB |
2_028.txt | RE | 121 ms | 768 KB |
2_029.txt | RE | 97 ms | 256 KB |
2_030.txt | RE | 122 ms | 768 KB |
2_031.txt | RE | 97 ms | 256 KB |
2_032.txt | RE | 121 ms | 768 KB |
2_033.txt | RE | 101 ms | 384 KB |
2_034.txt | RE | 123 ms | 768 KB |
2_035.txt | RE | 121 ms | 640 KB |
2_036.txt | RE | 122 ms | 768 KB |
2_037.txt | RE | 100 ms | 384 KB |
2_038.txt | RE | 122 ms | 768 KB |
2_039.txt | RE | 97 ms | 256 KB |
2_040.txt | RE | 121 ms | 768 KB |