ABC342 题解
A
Description
给定一个串 s s s,求与 s s s 中其它字符不同的唯一字符的编号。
Solution
直接把 s s s 存到 t t t 里排序(确实,sort(t.begin(), t.end())
就可以),首尾特判再到 s s s 里查一下就可以了。
Code
void solve(int testcase, ...){
init_vars();
string s; cin >> s;
string t = s; sort(t.begin(), t.end());
char ans;
if(t[0] != t[1]) ans = t[0];
else ans = t[t.length() - 1];
for(int i = 0; i < s.length(); i++){
if(s[i] == ans) cout << i + 1 <<endl;
}
}
B
Description
给定一个数列 a a a,表示 b a i = i \displaystyle{b_{a_i} = i} bai=i。
给定 q q q 次查询 x x x 和 y y y,求 b x b_x bx 是否小于 b y b_y b