답안 #1031059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031059 2024-07-22T14:05:32 Z 7again Pohlepko (COCI16_pohlepko) C++17
10 / 80
87 ms 55212 KB
#include <bits/stdc++.h>
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define in insert
#define all(x) x.begin(),x.end()
#define FAST ios::sync_with_stdio(0);cout.tie(0);cin.tie(0)

using namespace std ;

void slv()
{
    int n , m ;
    cin >> n >> m ;

    char a[n][m] ;
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            cin >> a[i][j] ;

    int dp[n][m] ;
    fill_n(&dp[0][0] , (n) * (m) , 0) ;

    pair <int , int> pos[n][m] ;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < m ; j++)
        {
            dp[i][j] += a[i][j] ;

            if(i == 0 && j == 0)
                continue ;

            if(j == 0)
            {
                dp[i][j] += a[i - 1][j] ;
                pos[i][j] = {i - 1 , j} ;
            }
            else if(i == 0)
            {
                dp[i][j] += a[i][j - 1] ;
                pos[i][j] = {i , j - 1} ;
            }
            else if(a[i - 1][j] < a[i][j - 1])
            {
                dp[i][j] += a[i - 1][j] ;
                pos[i][j] = {i - 1 , j} ;
            }
            else
            {
                dp[i][j] += a[i][j - 1] ;
                pos[i][j] = {i , j - 1} ;
            }
        }
    }

    pair <int , int> E = {n - 1 , m - 1} ;
    vector <char> ans ;
    while(1)
    {
        ans.pb(a[E.f][E.s]) ;

        if(E.f + E.s == 0)
            break ;

        E = pos[E.f][E.s] ;
    }

    reverse(all(ans)) ;

    for(auto t : ans)
        cout << t ;
}
main()
{
    FAST ;
    slv() ;
}

Compilation message

pohlepko.cpp:75:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   75 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 380 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Incorrect 5 ms 3676 KB Output isn't correct
7 Incorrect 27 ms 18648 KB Output isn't correct
8 Incorrect 87 ms 55148 KB Output isn't correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 1072 KB Output isn't correct
11 Incorrect 3 ms 1884 KB Output isn't correct
12 Incorrect 7 ms 4956 KB Output isn't correct
13 Incorrect 4 ms 3164 KB Output isn't correct
14 Incorrect 81 ms 55212 KB Output isn't correct
15 Incorrect 1 ms 604 KB Output isn't correct
16 Incorrect 25 ms 21852 KB Output isn't correct