QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#56485 | #2910. Rise and Fall | Silverhorse7# | AC ✓ | 29ms | 3780kb | C++ | 1.7kb | 2022-10-19 18:56:39 | 2022-10-19 18:56:41 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 69;
int n;
int perm[N], dep[N];
int l;
vector<vector<int>> adj;
int timer;
vector<int> tin, tout;
vector<vector<int>> up;
void dfs(int v, int p) {
tin[v] = ++timer;
dep[v] = dep[p] + 1;
up[v][0] = p;
for (int i = 1; i <= l; ++i)
up[v][i] = up[up[v][i - 1]][i - 1];
for (int u: adj[v]) {
if (u != p)
dfs(u, v);
}
tout[v] = ++timer;
}
bool is_ancestor(int u, int v) {
return tin[u] <= tin[v] && tout[u] >= tout[v];
}
int lca(int u, int v) {
if (is_ancestor(u, v))
return u;
if (is_ancestor(v, u))
return v;
for (int i = l; i >= 0; --i) {
if (!is_ancestor(up[u][i], v))
u = up[u][i];
}
return up[u][0];
}
void preprocess(int root) {
tin.resize(n + 69);
tout.resize(n + 69);
timer = 0;
l = ceil(log2(n + 69));
up.assign(n + 69, vector<int>(l + 1));
dfs(root, root);
}
int dis(int u, int v) {
return dep[u] + dep[v] - dep[lca(u, v)] * 2;
}
signed main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int T;
cin >> T;
while (T--) {
string s;
cin >> s;
int i = 0, n = s.size();
while (i < n and s[i] <= s[i + 1])
i++;
int ck = i - 1;
for (i = ck + 1; i < n - 1; i++)
if (s[i] < s[i + 1])break;
ck = i;
for (int i = 0; i < ck; i++)cout << s[i];
for (int i = ck; i < n; i++)cout << s[ck];
cout << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 29ms
memory: 3628kb
input:
22221 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 100 100 ...
result:
ok 22221 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3588kb
input:
1 81203
output:
81111
result:
ok single line: '81111'
Test #3:
score: 0
Accepted
time: 4ms
memory: 3716kb
input:
1 8147808841161076533069894579323933750148519021491962143504286500141250622416827740645669904579133432788986641975036999807060915645576550126891240755721919151651626566398914283777784133447710259412911998406658975794115346667678250669807533058166651327456477017294271327236068473114601523018648345755...
output:
811111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
ok single line: '811111111111111111111111111111...1111111111111111111111111111111'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3780kb
input:
1 5831547705729169345240362765024919993576553259252420218172763362568668911335592347219626281987701567689003720259437513024567202711198485902726569263700062551675189469675259584393481816239898106918244672383083789350709878093230949359781279167696438904477596174206116283773647485734468161872853869520...
output:
583111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
ok single line: '583111111111111111111111111111...1111111111111111111111111111111'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
1 5248760413215453424489482713387218758551638756130333667957690314913823581935431904185607869930759707072170039874318911554940926287359166744342040443090119621807344855842756339496619440651040898719679714337601387130583112351958890569192095196419227209998453589605960347133179788266032087649159730837...
output:
522222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...
result:
ok single line: '522222222222222222222222222222...2222222222222222222222222222222'
Test #6:
score: 0
Accepted
time: 3ms
memory: 3572kb
input:
1 1413863624630645501714417790649284612439472008981238913138158443476045236611475067362971767873807386505772242037025100582863008172210203726856066117259505624294521736410173459337355993938823892150350751339275813293503731574352908254844540852737830753264940954776210071527941353072145382484384568664...
output:
141111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
ok single line: '141111111111111111111111111111...1111111111111111111111111111111'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
2 29041 56577
output:
29000 56555
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 2ms
memory: 3612kb
input:
1 1000000
output:
1000000
result:
ok single line: '1000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
1 99999999
output:
99999999
result:
ok single line: '99999999'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3708kb
input:
1 111111111
output:
111111111
result:
ok single line: '111111111'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
1 98765432
output:
98765432
result:
ok single line: '98765432'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
1 12345
output:
12345
result:
ok single line: '12345'