QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#111076 | #6563. Four Square | KhNURE_KIVI# | WA | 86ms | 5944kb | C++17 | 3.7kb | 2023-06-05 19:18:54 | 2023-06-05 19:18:56 |
Judging History
answer
//#pragma GCC optimize("Ofast", "unroll-loops")
//#pragma GCC target("sse", "sse2", "sse3", "ssse3", "sse4")
#ifdef __APPLE__
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstdint>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <random>
#include <deque>
#include <functional>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <complex>
#include <numeric>
#include <cassert>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <thread>
#else
#include <bits/stdc++.h>
#endif
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
template<typename T>
bool umin(T &a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<typename T>
bool umax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
#if __APPLE__
#define D for (bool _FLAG = true; _FLAG; _FLAG = false)
#define LOG(...) print(#__VA_ARGS__" ::", __VA_ARGS__) << endl
template <class ...Ts> auto &print(Ts ...ts) { return ((cerr << ts << " "), ...); }
#else
#define D while (false)
#define LOG(...)
#endif
const int max_n = 800+10, inf = 1000111222;
int lcp[max_n][max_n];
int cnt_pref[max_n];
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;
// cin>>s;
s=string(800,'a');
const int n=len(s);
auto foo=[&](bool can_be_equal,const string& s)
{
for (int i=n-1;i>=0;i--){
for (int j=n-1;j>=0;j--){
if (s[i]==s[j]){
lcp[i][j] = 1 + lcp[i+1][j+1];
}
else{
lcp[i][j] = 0;
}
}
}
ll res=0;
for (int i=0;i<n;i++){
for (int j=i;j<n;j++){
bool flag=0;
for (int k=0;k<i;k++){
if (lcp[i][k]>=(j-i+1)){
flag=1;
break;
}
}
if (flag){
continue;
}
LOG(i,j);
for (int k=0;k<n;k++){
cnt_pref[k]=0;
}
for (int k=0;k<n;k++){
if (lcp[k][i]>=(j-i+1)){
cnt_pref[k]++;
}
}
for (int k=n-1;k>=0;k--){
cnt_pref[k]+=cnt_pref[k+1];
}
auto process=[&](int i,int j)
{
for (int l=(can_be_equal?i:i-1);l>=0 && j+(i-l)<n;l--){
if (lcp[l][j+1]>=(i-l)){
LOG(l,i,j,cnt_pref[j+(i-l)+1]);
res += cnt_pref[j+(i-l)+1];
}
}
};
for (int k=i;k+(j-i)<n;k++){
if (lcp[i][k]>=(j-i+1)){
process(k,k+(j-i));
}
}
}
}
return res;
};
ll ans=0;
ans+=foo(true,s);
reverse(all(s));
ans+=foo(false,s);
cout<<ans<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 86ms
memory: 5944kb
input:
1 1 1 1 1 1 1 1
output:
8554693400
result:
wrong answer 1st lines differ - expected: '1', found: '8554693400'