QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#484949 | #7700. Split Decisions | priudy | WA | 0ms | 3876kb | C++14 | 1.8kb | 2024-07-20 09:37:02 | 2024-07-20 09:37:02 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n;
string s[1505];
map<pair<string,string>,map<pair<string,string>,int> > nums;
void solve(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>s[i];
}
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
string m1="",m2="";
int pre=-1;int f=0,js=-1;
bool y=1;
for(int k=0;k<s[i].length();k++){
// cout<<s[i][k]<<" "<<pre<<" "<<js<<endl;
//cout<<k<<" ";
if(s[i][k]==s[j][k]&&f){
f=0;
js=k-1;
if(k-pre!=2){
y=0;
break;
}
}
if(s[i][k]!=s[j][k]){
m1+=s[i][k];
m2+=s[j][k];
f=1;
if(js>=0){
y=0;
break;
}
if(pre==-1)
pre=k;
}
}
// if(pre==-1)pre=0;
// cout<<endl;
if(js==-1){
if(s[i].length()-pre!=2){
y=0;
}
js=s[i].length()-1;
}
//cout<<pre<<" "<<js<<endl;
if(y){
// cout<<js<<" ";
// if(m1>m2)swap(m1,m2);
string p1=s[i].substr(0,pre);
string p2=s[i].substr(js,s[i].length()-js+1);
// cout<<s[i]<<" "<<s[j]<<"p1"<<p1<<"p"<<p2<<"p2"<<endl;
nums[make_pair(m1,m2)][make_pair(p1,p2)]++;
// nums[make_pair(m2,m1)][make_pair(p1,p2)]++;
}
}
}
int ans=0;
for(auto it:nums){
//cout<<it.first.first<<" "<<it.first.second<<endl;
//if(it.second.size()==1){
for(auto o:it.second){
if(o.second==1){
//cout<<o.first.first<<it.first.first<<o.first.second<<endl;
ans++;
}
}
//}
// cout<<ans/2<<endl;
}
cout<<ans;
return;
}
signed main() {
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3876kb
input:
5 CELL GULL GUSH HALL HASH
output:
6
result:
wrong answer 1st lines differ - expected: '2', found: '6'