2025 United Kingdom and Ireland Programming Contest (UKIEPC 2025) 2025 英国 ICPC——C. Colourful Captcha · znzryb
## 题目大意
## 题目总结:Colourful Captcha
本题要求构造一个符合特定条件的 ASCII 艺术矩形(验证码),以区分“简化模型(模拟机器人)”和“人类”的读取结果。
### 1. 核心约束
- **尺寸限制**:行数 $\le 10$,每行长度 $\le 100$ 且长度相等。
- **字符构成**:仅限大写英文字母和点 `.`。
- **人类读取 (**$C_1$**)**:
- 人类通过“大字母”的**孔洞数量**来识别颜色。
- **孔洞规则**:`B` 有 2 个孔;`A, D, O, P, Q, R` 有 1 个孔;其余字母 0 个孔。
- **识别单位**:由四连通字母组成的区域视为一个“大字母”。
- **识别顺序**:从左到右,且大字母的水平边界框(Bounding Box)不得相交或接触。
- **机器人读取 (**$C_2$**)**:
- 机器人直接扫描文本中的子串。
- **包含要求**:图中必须包含子串 $C_2$,且其两端不能紧邻其他字母(如 $C_2=\text{RED}$,允许 `.RED.`,禁止 `REDHAT`)。
- **排除要求**:图中严禁出现除 $C_2$ 以外的其他彩虹颜色名子串。
### 2. 彩虹颜色与孔洞对应表
| **颜色名** | **孔洞序列** |
| --- | --- |
| **RED** | 1, 0, 1 |
| **ORANGE** | 1, 1, 0, 1, 0, 0 |
| **YELLOW** | 0, 0, 0, 0, 1, 0 |
| **GREEN** | 0, 1, 0, 0, 0 |
| **BLUE** | 2, 0, 0, 0 |
| **VIOLET** | 0, 0, 1, 0, 0, 0 |
---
### 3. 样例解释
**输入**:$C_1 = \text{BLUE}$, $C_2 = \text{RED}$
**输出分析**:
```ascii art
BB..L...U.U.EEE <-- 第一部分:人类识别为 BLUE
B.B.L...U.U.E.. B(2孔), L(0孔), U(0孔), E(0孔)
BBB.L...U.U.EEE 四个大字母水平不接触,识别结果:BLUE
B.B.L...U.U.E..
RED.RED.RED.RED <-- 第二部分:机器人识别为 RED
包含子串 RED,且两端由点号或边界隔离
未包含 ORANGE, YELLOW 等其他子串
```
## 思路讲解
这道题目给出的构造条件非常的宽松,你甚至可以就是直接就是嗯每一列它都是用 s_ai 组成就行了。
```cpp
string s_human,s_ai;
cin>>s_human>>s_ai;
vector<string> ans_ls(12);
for (int i=1;i<=10;++i) {
for (int j=0;j<s_human.size();++j) {
ans_ls[i]+=s_ai;
ans_ls[i]+=".";
}
}
for (int i=0,idx=1;i<s_human.size();++i,idx+=SZ(s_ai)+1) {
char ch=s_human[i];
if (ch=='B') {
ans_ls[2][idx]='.';
ans_ls[9][idx]='.';
}else if (one_hole.contains(ch)) {
ans_ls[2][idx]='.';
}
}
for (int i=1;i<=10;++i) {
cout<<ans_ls[i]<<"\n";
}
```
那么你会看到叔叔就长成这样,直接使用 s_ai 的 red 啊去组成这样子一个列。violt的话只有O的部分是有一个呃空缺的,我们只要点一个点一个点就行。
```cpp
_______________[ Testcase #1 INPUT ]_______________
VIOLET
RED
_______________[ Testcase #1 OUTPUT]_______________
RED.RED.RED.RED.RED.RED.
RED.RED.R.D.RED.RED.RED.
RED.RED.RED.RED.RED.RED.
RED.RED.RED.RED.RED.RED.
RED.RED.RED.RED.RED.RED.
RED.RED.RED.RED.RED.RED.
RED.RED.RED.RED.RED.RED.
RED.RED.RED.RED.RED.RED.
RED.RED.RED.RED.RED.RED.
RED.RED.RED.RED.RED.RED.
```
## AC代码
AC
[https://qoj.ac/submission/2013731](https://qoj.ac/submission/2013731)
::: 源代码
```cpp
/**
* Problem: C. Colourful Captcha
* Contest: 2025 United Kingdom and Ireland Programming Contest (UKIEPC 2025)
* Judge: Codeforces
* URL: https://codeforces.com/gym/106157/problem/C
* Created: 2026-02-07 13:33:24
* Author: Gospel_rock
*
* Powered by AutoCp https://github.com/Pushpavel/AutoCp
*/
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define lson(o) (o<<1)
#define rson(o) (o<<1|1)
#define SZ(a) ((long long) a.size())
#define debug(var) cerr << #var <<":"<<var<<"\n";
#define cend cerr<<"\n-----------\n"
#define fsp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using DB = double;
// using i128 = __int128;
using CD = complex<double>;
static constexpr ll MAXN = (ll)1e6+10, INF = (1ll<<61)-1;
static constexpr ll mod = 998244353; // (ll)1e9+7;
static constexpr double eps = 1e-8;
const double pi = acos(-1.0);
ll lT,testcase;
/*
*
*/
set<char> one_hole={'A','D','O','P','Q','R'};
void Solve() {
// ll N;
// cin >> N;
string s_human,s_ai;
cin>>s_human>>s_ai;
vector<string> ans_ls(12);
for (int i=1;i<=10;++i) {
for (int j=0;j<s_human.size();++j) {
ans_ls[i]+=s_ai;
ans_ls[i]+=".";
}
}
for (int i=0,idx=1;i<s_human.size();++i,idx+=SZ(s_ai)+1) {
char ch=s_human[i];
if (ch=='B') {
ans_ls[2][idx]='.';
ans_ls[9][idx]='.';
}else if (one_hole.contains(ch)) {
ans_ls[2][idx]='.';
}
}
for (int i=1;i<=10;++i) {
cout<<ans_ls[i]<<"\n";
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef LOCAL
cout.setf(ios::unitbuf); // 无缓冲流,方便我们调试
#endif
// cin >> lT;
// for (testcase=1;testcase<=lT;++testcase)
Solve();
return 0;
}
/*
AC
https://qoj.ac/submission/2013731
*/
```
:::
## 心路历程(WA,TLE,MLE……)