QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#714719 | #5680. You You See What? | zeyu# | AC ✓ | 0ms | 3856kb | C++23 | 2.8kb | 2024-11-06 03:43:32 | 2024-11-06 03:43:32 |
Judging History
answer
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pl pair<ll, ll>
#define pi pair<int, int>
#define minpq priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;
#if 1
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '['; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "]";}
void _print() {cerr << endl << flush;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "*["<<__LINE__<<"]\t"<< #x << " = "; _print(x)
#endif
const ll mod = 1e9 + 7;
template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll gcd(ll a, ll b) {if(b == 0){return a;} return gcd(b, a % b);}
char tolower(char c){
if (c >= 'a' && c <= 'z') return c;
else return c - 'A' + 'a';
}
bool same(string s1, string s2){
if (s1.size() != s2.size()) return false;
for (int i = 0; i < s1.size(); i ++){
char c1 = tolower(s1[i]);
char c2 = tolower(s2[i]);
if (c1 != c2) return false;
}
return true;
}
vector<string> simp(vector<string> a){
int n = a.size();
for (int i = 0; i < n - 3; i ++){
if (same(a[i], a[i + 2])){
vector<string> ans;
for (int k = 0; k <= i; k ++) ans.push_back(a[k]);
for (int k = i + 3; k < n; k ++) ans.push_back(a[k]);
return ans;
}
}
for (int i = 0; i < n - 2; i ++){
if (same(a[i], a[i + 1])){
vector<string> ans;
for (int k = 0; k <= i; k ++) ans.push_back(a[k]);
for (int k = i + 2; k < n; k ++) ans.push_back(a[k]);
return ans;
}
}
return a;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
string s; cin >> s;
int n = s.size();
vector<string> a;
int x = 0, len = 0;
while(x < n){
while(x + len < n && s[x + len] != '!') len ++;
a.push_back(s.substr(x, len));
x += len + 1; len = 0;
}
while(true){
int orig = a.size();
a = simp(a);
if (a.size() == orig) break;
}
for (int i = 0; i < a.size() - 1; i ++) cout << a[i] << "!";
cout << a.back();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3796kb
input:
texasam!rice!baylor!csdept!baylor!rice!dev!bresearch!bpoucher
output:
texasam!rice!dev!bresearch!bpoucher
result:
ok single line: 'texasam!rice!dev!bresearch!bpoucher'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
texasam!Rice!baYlor!csdept!BayloR!dev!Rice!bresearch!bpoucher
output:
texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher
result:
ok single line: 'texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
bresearch!bpoucher
output:
bresearch!bpoucher
result:
ok single line: 'bresearch!bpoucher'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!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m!n!o!p!q!r!s!t!u!v!w!xx
result:
ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z
output:
a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z
result:
ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
abcdEFGHij!bbcdEFGHij!cbcdEFGHij!dbcdEFGHij!ebcdEFGHij!fbcdEFGHij!gbcdEFGHij!hbcdEFGHij!ibcdEFGHij!jbcdEFGHij!kbcdEFGHij!lbcdEFGHij!mbcdEFGHij!nbcdEFGHij!obcdEFGHij!pbcdEFGHij!qbcdEFGHij!rbcdEFGHij!sbcdEFGHij!tbcdEFGHij!ubcdEFGHij!vbcdEFGHij!wbcdEFGHij!abc
output:
abcdEFGHij!bbcdEFGHij!cbcdEFGHij!dbcdEFGHij!ebcdEFGHij!fbcdEFGHij!gbcdEFGHij!hbcdEFGHij!ibcdEFGHij!jbcdEFGHij!kbcdEFGHij!lbcdEFGHij!mbcdEFGHij!nbcdEFGHij!obcdEFGHij!pbcdEFGHij!qbcdEFGHij!rbcdEFGHij!sbcdEFGHij!tbcdEFGHij!ubcdEFGHij!vbcdEFGHij!wbcdEFGHij!abc
result:
ok single line: 'abcdEFGHij!bbcdEFGHij!cbcdEFGH...FGHij!vbcdEFGHij!wbcdEFGHij!abc'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abc
output:
abcdEFGHij!abc
result:
ok single line: 'abcdEFGHij!abc'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb
output:
a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb
result:
ok single line: 'a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!...!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!B
output:
aa!B
result:
ok single line: 'aa!B'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
b
output:
b
result:
ok single line: 'b'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
bpoucher
output:
bpoucher
result:
ok single line: 'bpoucher'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
Abcdefghij
output:
Abcdefghij
result:
ok single line: 'Abcdefghij'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
polyof!johnb
output:
polyof!johnb
result:
ok single line: 'polyof!johnb'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
polyvm!polyof!gracie!johnb
output:
polyvm!polyof!gracie!johnb
result:
ok single line: 'polyvm!polyof!gracie!johnb'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
a!b!b!c!c!d!d!d!e!e!e
output:
a!b!c!d!e!e
result:
ok single line: 'a!b!c!d!e!e'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
aaaa!bbbbb!bbbbb!testacct
output:
aaaa!bbbbb!testacct
result:
ok single line: 'aaaa!bbbbb!testacct'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b
output:
a!b!b
result:
ok single line: 'a!b!b'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!bb!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b
output:
a!b!b
result:
ok single line: 'a!b!b'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!c!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b
output:
a!b!b
result:
ok single line: 'a!b!b'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!c!d!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b
output:
a!b!c!d!b!b
result:
ok single line: 'a!b!c!d!b!b'