题目大意
题目总结:Colourful Captcha
本题要求构造一个符合特定条件的 ASCII 艺术矩形(验证码),以区分“简化模型(模拟机器人)”和“人类”的读取结果。
1. 核心约束
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. 样例解释
输入:C1=BLUE, C2=RED
输出分析:
art1 2 3 4 5 6 7
| 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 组成就行了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| 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的部分是有一个呃空缺的,我们只要点一个点一个点就行。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| _______________[ 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
源代码
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
|
#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 CD = complex<double>;
static constexpr ll MAXN = (ll)1e6+10, INF = (1ll<<61)-1; static constexpr ll mod = 998244353; 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() { 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
Solve(); return 0; }
|
心路历程(WA,TLE,MLE……)