답안 #883686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883686 2023-12-05T17:36:53 Z Esgeer Pohlepko (COCI16_pohlepko) C++17
40 / 80
47 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("Ofast,O3,unroll-loops")
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpi vector<pii>
#define vvpi vector<vpi>
#define vb vector<bool>
#define vvb vector<vb>
#define endl "\n"
#define sp << " " <<
#define F(i, s, n) for(int i = s; i < n; i++)
#define pb push_back
#define fi first
#define se second
 
const int mod = 1e8;
 
int inf = LLONG_MAX >> 4;

int add(int x, int y) {
    return (x + y) % mod;
}
int mult(int x, int y) {
    return ((x % mod) * (y % mod)) % mod;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<string> grid(n);
    F(i, 0, n) cin >> grid[i];

    string dp[n][m];
    dp[0][0] = string(1, grid[0][0]);
    F(i, 0, n) {
        F(j, 0, m) {
            if(i == 0 && j == 0) continue; 
            if(i == 0) dp[i][j] = dp[i][j-1];
            else if(j == 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j], dp[i][j-1]);

            dp[i][j] += grid[i][j];
        }
    }
    cout << dp[n-1][m-1] << endl;
}
 
void setIO() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef Local
        freopen("local.in", "r", stdin);
        freopen("local.out", "w", stdout);
    #else 
        //freopen("snakes.in","r",stdin);
        //freopen("snakes.out","w",stdout);
    #endif
}
signed main() {
    setIO();
    int t = 1;
    //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 4 ms 8540 KB Output is correct
6 Runtime error 35 ms 65536 KB Execution killed with signal 9
7 Runtime error 37 ms 65536 KB Execution killed with signal 9
8 Runtime error 39 ms 65536 KB Execution killed with signal 9
9 Correct 1 ms 1372 KB Output is correct
10 Correct 21 ms 33584 KB Output is correct
11 Runtime error 32 ms 65536 KB Execution killed with signal 9
12 Runtime error 47 ms 65536 KB Execution killed with signal 9
13 Runtime error 34 ms 65536 KB Execution killed with signal 9
14 Runtime error 44 ms 65536 KB Execution killed with signal 9
15 Correct 3 ms 4700 KB Output is correct
16 Runtime error 46 ms 65536 KB Execution killed with signal 9