QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#554038 | #2748. Lost is Close to Lose | Tenshi# | WA | 10ms | 3868kb | C++20 | 1.8kb | 2024-09-09 02:29:35 | 2024-09-09 02:29:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << ": " << (x) << endl
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dwn(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
using pii = pair<int, int>;
using ll = long long;
inline void read(int &x){
int s=0; x=1;
char ch=getchar();
while(ch<'0' || ch>'9') {if(ch=='-')x=-1;ch=getchar();}
while(ch>='0' && ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
x*=s;
}
map<string, set<string>> res;
vector<string> d;
string work(string &s){
string res;
for(auto e: s) if(isalpha(e)) res+=tolower(e);
return res;
}
bool ok(string a, string b){
if(a==b) return false;
if(a.size()>b.size()) swap(a, b);
if(a.size()==b.size()){
int cnt=0;
rep(i, 0, (int)a.size()-1) if(a[i]!=b[i]) cnt++;
if(cnt==1) return true;
if(cnt==2){
rep(i, 0, (int)a.size()-2){
if(a[i]==b[i+1] && a[i+1]==b[i]) return true;
}
}
}
else if(a.size()+1==b.size()){
bool fl=true;
int idx=0;
rep(i, 0, (int)b.size()-1){
if(a[idx]!=b[i]){
if(!fl) return false;
fl=false;
}
else{
idx++;
}
}
return true;
}
return false;
}
signed main(){
string s;
while(getline(cin, s)){
if(s=="***") break;
stringstream ssin(s);
string tmp;
while(ssin>>tmp){
tmp=work(tmp);
if(tmp=="") continue;
for(auto &t: d){
if(ok(t, tmp)){
res[t].insert(tmp);
res[tmp].insert(t);
}
}
d.pb(tmp);
}
}
// debug(ok("close", "lose"));
// for(auto &e: d) debug(e);
bool fl=false;
for(auto &[x, y]: res){
fl=true;
cout<<x<<": ";
for(auto e: y) cout<<e<<" ";
puts("");
}
if(!fl) puts("***");
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
Lost is Close to Lose "Better Documents Inc. wants to add Typo Checking in to the next generation of word processors," he said. ***
output:
close: lose he: the in: inc is inc: in is: in lose: close lost lost: lose the: he
result:
ok 8 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
The fox said, "When?" "Not till 12 o'clock", replied the hen. "That clock is stopped, it will never strike.", he said. ***
output:
clock: oclock he: hen the hen: he when is: it it: is oclock: clock the: he till: will when: hen will: till
result:
ok 10 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
There are no similar words in this input set. ***
output:
***
result:
ok single line: '***'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
Word words line "lines" "" a paragraph parag23raphs chapters 0chapter book books99 store STORES ***
output:
book: books books: book chapter: chapters chapters: chapter line: lines lines: line paragraph: paragraphs paragraphs: paragraph store: stores stores: store word: words words: word
result:
ok 12 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
food foods shoes shoe she hoe he her hero heron ***
output:
food: foods foods: food he: her hoe she her: he hero hero: her heron heron: hero hoe: he shoe she: he shoe shoe: hoe she shoes shoes: shoe
result:
ok 10 lines
Test #6:
score: -100
Wrong Answer
time: 10ms
memory: 3868kb
input:
It was the best of times,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it w...
output:
a: an as at p an: a and any as at in on and: an any any: an and as: a an at is us was at: a an as it away: way be: by he we but: cut out put by: be come: some cut: but out put day: way dead: head do: go no so to down: town even: ever seven ever: even every every: ever very face: f...
result:
wrong answer 27th lines differ - expected: 'got: go not', found: 'good: took '