답안 #124861

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124861 2019-07-04T04:46:56 Z 윤교준(#3050) Necklace (Subtask 1-3) (BOI19_necklace1) C++14
0 / 85
6 ms 376 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[sz(V)-2])
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;

int D[305][305];

char A[305], B[305];

int N, M, Ans;

void solve() {
	for(int i = 1; i <= N; i++) {
		for(int j = 1; j <= M; j++) {
			D[i][j] = max(D[i-1][j], D[i][j-1]);
			if(A[i] == B[j]) {
				upmax(D[i][j], D[i-1][j-1] + 1);
			}
		}
	}
	upmax(Ans, D[N][M]);
}

int main() {
	scanf(" %s %s", A+1, B+1);
	N = strlen(A+1);
	M = strlen(B+1);

	for(int t = 0; t < M; t++) {
		rotate(B+1, B+2, B+M+1);
		solve();
	}

	cout << Ans << endl;
	return 0;
}

Compilation message

necklace.cpp: In function 'int main()':
necklace.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %s %s", A+1, B+1);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -