제출 #104148

#제출 시각아이디문제언어결과실행 시간메모리
104148leonardaPohlepko (COCI16_pohlepko)C++14
0 / 80
83 ms66560 KiB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int maxn = 2000 + 5;
int n, m;
char a[maxn][maxn];
string dp[maxn][maxn];

int nadi(string s, string t) {
	for(int i = 0; i < s.size(); ++i)
		if(s[i] != t[i])
			return i;
	return -1; //stringovi su isti
}

int main ()
{
	ios::sync_with_stdio(0);
	
	cin >> n >> m;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j)
			cin >> a[i][j];
	
	dp[0][0].pb(a[0][0]);
	
	for(int i = 1; i < m; ++i)
		dp[0][i] = dp[0][i - 1] + a[0][i];
	for(int i = 1; i < n; ++i)
		dp[i][0] = dp[i - 1][0] + a[i][0];
	
	for(int i = 1; i < n; ++i) {
		for(int j = 1; j < m; ++j) {
			
			string s = dp[i - 1][j];
			string t = dp[i][j - 1];
			int raz = nadi(s, t);
			
			if(raz == -1)
				dp[i][j] = s + a[i][j];
			else {
				if(s[raz] < t[raz])
					dp[i][j] = s + a[i][j];
				else
					dp[i][j] = t + a[i][j];
			}
			
		}	
	}
	
	cout << dp[n - 1][m - 1];

return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

pohlepko.cpp: In function 'int nadi(std::__cxx11::string, std::__cxx11::string)':
pohlepko.cpp:10:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < s.size(); ++i)
                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...