最近发烧发到 38 度了(倒闭了
却教练还要让我做模拟赛(恼
之前教练让我做这个一个一个一个 joisc2024
然后发现有两道通信题洛谷和学校 oj 都没有搬
然后就点开其中一道题做了一下
进行了一些思考(思考 114/514)
然后一交假完了
然后又进行了一些思考(思考 154/514)
一交发现 都过了
然后因为 joi 的妙妙通信题部分分配置,虽然只有 40 分,但是显示 AC
那就当它过了吧,反正史上就没几个人做过这道题
就当个题解吧
[JOISC2024] E - 三色灯 (Tricolor Lights)
洛谷并没有搬这道题
https://www2.ioi-jp.org/camp/2024/2024-sp-tasks/index.html
首先考虑这个 Anti 比较难搞,有没有什么方法刻画成固定的信息
答案是肯定的,不难发现可以刻画相邻的两个数是相同还是不同
然后你就把整个字符串两的分一组,看它是否相等,然后就变成了一个 10 串,就能刻画了
但是块与块之间的相等情况貌似是没有方法确定的,导致这个就被什么 RGRGGGGRGRGRGGRGRGG 给卡了。
哎发烧讲不清楚
但是你可以从所有可行的方案(期望 个)随机一个出来,这样块于快间的情况也是随机的,就行了
随机 01 序列, 能过掉,但是 就被生日悖论击杀了。
最近头脑火热爆炸,没有继续想,倒闭了
const int N = 5e5 + 5;
const int B = 3331;
int n, len, a[N], b[N];
ull pw[N], h[N];
map<ull, int> mp;
pair<string, int> anna(int _n, string s) {
n = _n;
s = ' ' + s;
FOR(i, 1, n) {
if(s[i] == 'R') a[i] = 0;
if(s[i] == 'G') a[i] = 1;
if(s[i] == 'B') a[i] = 2;
}
mt19937 rnd(114);
mt19937 rndr(time(0));
FOR(i, 1, n / 2) {
vector<PII> f;
if(rnd() % 2) {
REP(l, 3) if(l != a[i * 2 - 1])
REP(r, 3) if(r != a[i * 2])
if(l == r) f.push_back({l, r});
}
else {
REP(l, 3) if(l != a[i * 2 - 1])
REP(r, 3) if(r != a[i * 2])
if(l != r) f.push_back({l, r});
}
auto h = f[rndr() % SZ(f)];
tie(b[i * 2 - 1], b[i * 2]) = h;
}
if(n % 2) b[n] = (a[n] + 1) % 3;
string t;
FOR(i, 1, n) {
if(b[i] == 0) t += 'R';
if(b[i] == 1) t += 'G';
if(b[i] == 2) t += 'B';
}
int len = min(129, n);
return {t, len};
}
void init(int _n, int _l) {
n = _n, len = _l;
mt19937 rnd(114);
FOR(i, 1, n / 2) a[i] = rnd() % 2;
pw[0] = 1;
FOR(i, 1, n) pw[i] = pw[i - 1] * B;
FOR(i, 1, n / 2) h[i] = h[i - 1] + pw[i] * a[i];
mp.clear();
FOR(i, 1, n / 2 - len / 2 + 1) {
int l = i, r = l + len / 2 - 1;
ull val = (h[r] - h[l - 1]) * pw[n - l];
mp[val] = i;
}
}
int bruno(string s) {
if(len == n) return 1;
ull res = 0;
REP(i, len / 2) if(s[i * 2] == s[i * 2 + 1]) res += pw[i];
res *= pw[n];
if(mp.count(res)) return mp[res] * 2 - 1;
res = 0;
REP(i, len / 2) if(s[i * 2 + 1] == s[i * 2 + 2]) res += pw[i];
res *= pw[n];
if(mp.count(res)) return mp[res] * 2 - 2;
return - 1;
}