제출 #1031059

#제출 시각아이디문제언어결과실행 시간메모리
10310597againPohlepko (COCI16_pohlepko)C++17
10 / 80
87 ms55212 KiB
#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) 메시지

pohlepko.cpp:75:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   75 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...