QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#69017 | #5119. Perfect Word | zhuibao | WA | 9ms | 6688kb | C++20 | 1.5kb | 2022-12-22 16:16:26 | 2022-12-22 16:16:29 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#include<unordered_map>
#include<unordered_set>
#include<bits/stdc++.h>
#include<array>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pi;
#define int ll
#define X first
#define Y second
#define fer(i,a,n) for(ll i=a;i<=n;i++)
#define ref(i,n,a) for(ll i=n;i>=a;i--)
#define endl '\n'
#define mem(a,x) memset(a,x,sizeof a)
#define ac IO;int t;cin>>t;while(t--)solve()
#define AC signed main(){IO;solve();}
#define NO {cout<<"No"<<endl;return;}
#define YES {cout<<"yes"<<endl;return;}
#define re(a) {cout<<a<<endl;return;}
#define all(v) v.begin(),v.end()
//ofstream fout("out.txt", ios::out);
//ifstream fin("in.txt", ios::in);
//#define cout fout
//#define cin fin
//--------------------瑞神神中神--------------------
const int N = 1e5 + 10;
set<string>se;
string s[N];
bool cmp(string a, string b)
{
if (a.size() ^ b.size())return a.size() < b.size();
return a < b;
}
void solve()
{
int n;
cin >> n;
fer(i, 1, n)
{
cin >> s[i];
}
sort(s + 1, s + n + 1, cmp);
int ans = 0;
fer(i, 1, n)
{
bool flag = 1;
int len = s[i].size();
for (int j = 0; j < len; j++)
{
string res;
if (j > 0)res += s[i].substr(0, j);
if (j < len - 1)res += s[i].substr(j + 1, len - j - 1);
if (res.size() > 0 && se.find(res) == se.end())
{
flag = 0;
break;
}
}
if (flag)
{
se.insert(s[i]);
ans = len;
}
}
cout << ans << endl;
}
AC
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 6504kb
input:
4 a t b ab
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 9ms
memory: 6552kb
input:
310 a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa aaaaaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa...
output:
300
result:
ok 1 number(s): "300"
Test #3:
score: -100
Wrong Answer
time: 5ms
memory: 6688kb
input:
4347 bbaaaab aabab bbaaaaababaaaba aababaaaabbbabababaaaba ababbabbbbbabbbabbab bbbbbbb bbbabbbabbabaab aabbbbabbbbaa aabaaabbbbbabaaababaa aaabababba aaababbaabab abbababbabbab bababaabbbbaaa aaaaaabaaaababaa ababaababba babaababbbababaaab bb abbbaaaababa b ab aaabbbbb abaabaaaaababbbab bbaaabaab b...
output:
8
result:
wrong answer 1st numbers differ - expected: '10', found: '8'