QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554039 | #2748. Lost is Close to Lose | Tenshi# | AC ✓ | 20ms | 3852kb | C++20 | 1.8kb | 2024-09-09 02:34:30 | 2024-09-09 02:34:31 |
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] && a[i]!=b[i] && a[i+1]!=b[i+1]) 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3824kb
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: 3548kb
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: 3772kb
input:
There are no similar words in this input set. ***
output:
***
result:
ok single line: '***'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3532kb
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: 3604kb
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: 0
Accepted
time: 6ms
memory: 3804kb
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:
ok 114 lines
Test #7:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
Would you eat them In a box? Would you eat them With a fox? Not in a box. Not with a fox. Not in a house. Not with a mouse. I would not eat them here or there. I would not eat them anywhere. I would not eat green eggs and ham. I do not like them, Sam I am. ***
output:
a: am i am: a ham sam box: fox fox: box ham: am sam here: there house: mouse i: a in in: i mouse: house sam: am ham there: here
result:
ok 12 lines
Test #8:
score: 0
Accepted
time: 20ms
memory: 3852kb
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 was the spring of hope, it was the winter of despair, we had everyt...
output:
a: an as at all: ball hall an: a and any as at in on and: an any hand any: an and as: a an at has is us was at: a an as it st away: way ball: all hall be: by he we best: rest body: boy boy: body by but: cut out put by: be boy came: come come: came some creature: creatures creatures...
result:
ok 156 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
cat hat bat bar hot hit car ***
output:
bar: bat car bat: bar cat hat car: bar cat cat: bat car hat hat: bat cat hit hot hit: hat hot hot: hat hit
result:
ok 7 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
coast coats cat ocats ocast cotas cot ***
output:
cat: cot coast: coats ocast coats: coast cotas ocats cot: cat cotas: coats ocast: coast ocats ocats: coats ocast
result:
ok 7 lines
Test #11:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
How much wood would a woodchuck chuck if a woodchuck could chuck wood? ***
output:
could: would would: could
result:
ok 2 lines