Submission #538045

#TimeUsernameProblemLanguageResultExecution timeMemory
538045skittles1412Necklace (Subtask 1-3) (BOI19_necklace1)C++17
25 / 85
1585 ms304 KiB
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
	cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
	cerr << t << " | ";
	dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                           \
	cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
		 << ": ";                                          \
	dbgh(__VA_ARGS__)
#else
#define cerr   \
	if (false) \
	cerr
#define dbg(...)
#endif

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

bool eqr(string s, const string &t) {
	for (int i = 0; i < sz(s); i++) {
		if (s == t) {
			return true;
		}
		rotate(s.begin(), s.begin() + 1, s.end());
	}
	return false;
}

bool eq(string s, const string &t) {
	if (eqr(s, t)) {
		return true;
	}
	reverse(begin(s), end(s));
	return eqr(s, t);
}

void solve() {
	dbg(eq("a", "b"));
	string s, t;
	cin >> s >> t;
	int n = sz(s), m = sz(t);
	for (int i = n; i >= 1; i--) {
		for (int j = 0; j + i <= n; j++) {
			for (int k = 0; k + i <= m; k++) {
				if (eq(s.substr(j, i), t.substr(k, i))) {
					cout << i << endl;
					cout << j << " " << k << endl;
					return;
				}
			}
		}
	}
	assert(false);
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cin.exceptions(ios::failbit);
	solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...