QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#603915 | #9350. Fixing Banners | Saton | TL | 1ms | 3532kb | C++20 | 1.5kb | 2024-10-01 20:56:54 | 2024-10-01 20:57:00 |
Judging History
answer
///by Saton.
#include<bits/stdc++.h>
#define PI acos(-1)
#define fi first
#define se second
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define LL long long
#define ll __int128
#define DD double double
#define LD long double
#define rep(i,a,b) for(LL i = (a);i <= (b);i ++)
#define lep(i,a,b) for(LL i = (a);i >= (b);i --)
#define FLUSH fflush(stdout)
using namespace std;
const int N = 2e5 + 10,mod = 1e9+7,P = 131;
const LL inf = 1e9+10,INF = 1e18+10;
typedef pair<int,int> PII;
typedef pair<LL,int> PLI;
typedef pair<LL,LL> PLL;
LL n,m,k;
string str;
string target = " harbin";
bool a[7][7];
bool dfs(int step,int pos,int state,string now) {
if(a[pos][step]) now += target[step];
else now += "?";
if(step==6) {
// if(now==target) cout << state << " " << now<< '\n';
return (now==target);
}
bool ans = false;
rep(i,1,6) {
if(state>>i&1) continue;
ans |= dfs(step+1,i,state|(1<<i),now);
}
return ans;
}
void solve() {
rep(i,0,6) rep(j,0,6) a[i][j] = false;
rep(i,1,6) {
cin >> str;
rep(j,0,sz(str)-1) rep(k,1,6) a[i][k] |= (str[j]==target[k]);
}
bool ans = false;
rep(i,1,6) ans |= dfs(1,i,1<<i," ");
cout << (ans ? "Yes" : "No") << '\n';
}
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int T;
cin >> T;
while(T --) {
solve();
}
// solve();
return 0;
}
/* /\_/\
* (= ._.)
* / > \>
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3532kb
input:
2 welcome toparticipate inthe ccpccontest inharbin inoctober harvest belong ninja reset amazing intriguing
output:
No Yes
result:
ok 2 lines
Test #2:
score: -100
Time Limit Exceeded
input:
50000 dwwfplbjd elulqfmsp whobggs kbnhtvzcs zllux ggye vtnqpmvi cgsplau gkuwhhmrio sp q utrefny tvdcequdjj klesyx esovlmdy x nywu gklfbqfb ysnaswszfq ouo tq r auvi copeabvz nruvawao cdv vdsk hboecpit s ewscbmb jeqp gel u htk fcoigxbux ylinyzut bnhrvoetf xa ehnbce keyk efvzoyba xan tvnlm tetpijfh blq...
output:
No No No No No No No No No No No No No No No No No No Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No...