QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#119930#6567. Repetitive String Inventioncada_dia_mas_insanosWA 32ms4784kbC++171.8kb2023-07-06 05:28:532023-07-06 05:28:56

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 05:28:56]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:4784kb
  • [2023-07-06 05:28:53]
  • 提交

answer

// Too many mind, no mind.
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
#include <iomanip>

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define COMP(x) sort(ALL(x)); x.resize(unique(ALL(x)) - (x).begin())
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

using pii = pair <int, int>;
using vi = vector <int>;
using vpi = vector <pii>;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using ld = long double;
using vld = vector<ld>;

const int maxn = 810;
int n;
char a[maxn];
int lcs[maxn][maxn];
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> a;
	n = strlen(a);
	forn(i, n) fore(j, i, n-1) {
		int k=0;
		while (i + k < j && j + k < n && a[j+k] == a[i+k]) k++;
		lcs[i][j] = k;
	}

	ll ans = 0;
	forn(i, n) fore(j, i, n-1) {
		fore(k, j+1, n-1) ans += lcs[i][k] >= j-i + 1;
	}

	forn(i, n) fore(j, i, n-1) {
		for (int c=0, k=n-1, l=0; c<i; c++) {
			int len  = i-c;
			if (lcs[c][j+1] < len) continue;
			while (k>j+len) {
				if (lcs[i][k] >= j-i+1) ans++;
				k--;
			}
			while (l<i-len) {
				if (lcs[l][i] >= j-i+1) ans++;
				l++;
			}
		}
	}

	cout << ans << endl;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3368kb

input:

aaaa

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3440kb

input:

axabxbcxcdxd

output:

22

result:

ok single line: '22'

Test #3:

score: -100
Wrong Answer
time: 32ms
memory: 4784kb

input:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...

output:

15939702

result:

wrong answer 1st lines differ - expected: '536006700', found: '15939702'