# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
922057 | jpfr12 | Pohlepko (COCI16_pohlepko) | C++17 | 54 ms | 65536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <fstream>
#include <bitset>
#include <iomanip>
typedef long long ll;
using namespace std;
int MOD = (int)1e9;
int MAXN = 1e6;
//classes
//global
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
//ifstream fin("teamwork.in");
//ofstream fout("teamwork.out");
//stop
int n, m;
cin >> n >> m;
vector<string> vec(n);
for(string& i: vec) cin >> i;
vector<vector<string>> dp(n, vector<string>(m, ""));
//first row
for(int i = 0; i < m; i++){
if(i == 0) dp[0][0] += vec[0][0];
else dp[0][i] = dp[0][i-1] + vec[0][i];
}
//first col
for(int i = 1; i < n; i++){
dp[i][0] = dp[i-1][0] + vec[i][0];
}
for(int i = 1; i < n; i++){
for(int j = 1; j < m; j++){
dp[i][j] = min(dp[i-1][j] + vec[i][j], dp[i][j-1] + vec[i][j]);
}
}
cout << dp[n-1][m-1] << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |