# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1031059 | 7again | Pohlepko (COCI16_pohlepko) | C++17 | 87 ms | 55212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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() ;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |