/*
和上題一樣只不過,是換成了檢驗答案,還是找規律,
自己看看吧awa
*/
// O(n)
#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <ctime>
using namespace std;
int n, m;
string s;
char get(char a, char b)
{
int sum = 0;
if (a == '0' || b == '0') sum ++ ;
if (sum == 1 && (a == '1' || b == '1')) sum ++ ;
return sum + '0';
}
string make(string s1)
{
string s2;
int len = s1.size() - 1;
for (int i = 0; i < len; i ++ )
{
s2 += get(s1[i], s1[i + 1]);
}
return s2;
}
int main()
{
freopen("out.txt", "r", stdin);
freopen("ans.txt", "w", stdout);
int T;
cin >> T;
while (T -- )
{
cin >> n;
s.clear();
for (int i = 0; i < n; i ++ )
{
char c[2];
scanf("%s", c);
if (c[0] > '1') c[0] = '2';
s += c[0];
}
n -= 1;
s = make(s);
if (n & 1)
{
n /= 2;
s = s.substr(n, 1);
}
else
{
n /= 2;
n -- ;
s = s.substr(2, 2);
make(s);
}
if (s.size() == 1 && s.compare("2") == 0) cout << "Yes";
else cout << "No";
puts("");
}
cout << clock();
}
/*
O(n^2)
#include <iostream>
#include <algorithm>
using namespace std;
int n, m;
string s;
char get(char a, char b)
{
int sum = 0;
if (a == '0' || b == '0') sum ++ ;
if (sum == 1 && (a == '1' || b == '1')) sum ++ ;
return sum + '0';
}
string make(string s1)
{
string s2;
int len = s1.size() - 1;
for (int i = 0; i < len; i ++ )
{
s2 += get(s1[i], s1[i + 1]);
}
return s2;
}
int main()
{
int T;
cin >> T;
while (T -- )
{
cin >> n;
s.clear();
for (int i = 0; i < n; i ++ )
{
char c;
cin >> c;
s += c;
// cout << c;
}
// cout << s << endl;
while ( -- n) s = make(s);
if (s[0] == '2') cout << "Yes";
else cout << "No";
puts("");
}
}
*/
T434199 「LAOI-4」Mex Tower (Hard ver.)
相關文章
- T429423 「LAOI-4」Mex Tower (Easy ver.)
- P11059 [入門賽 #27] 數字 (Hard Ver.)題解
- T422088 「LAOI-4」Colors
- C. MEX Game 1GAM
- ABC 308E MEX
- Reverse Card (Hard Version)
- git reset --hard HEAD^Git
- CF1905D Cyclic MEX 題解
- Is programming an Operating System so hard?
- NP-Hard問題
- CF1744F MEX vs MED 題解
- 並查集解mex_cf932_B. Informatics in MAC並查集ORMMac
- C2. Magnitude (Hard Version)
- C2. Potions (Hard Version)
- 【PR #12】劃分序列 / Yet Another Mex Problem 題解
- matlab中出現mex無法編譯的問題Matlab編譯
- D2. Set To Max (Hard Version)
- D2. Reverse Card (Hard Version)
- C2. Adjust The Presentation (Hard Version)
- 容斥定理 AtCoder——FizzBuzz Sum Hard
- git程式碼回退--hard的坑Git
- BZOJ4589: Hard Nim(FWT 快速冪)
- [AGC001E] BBQ Hard題解GC
- DevOps is Hard、DevSecOps is Even Harder. --- Enterprise Holdidev
- 2020MRCTF(Re)-Hard-to-go(WP)Go
- 11-雜湊4 Hashing - Hard Version
- Codeforces Global Round 11 C. The Hard Work of Paparazzi
- [題解]CF958C3 Encryption (hard)
- C2. Errich-Tac-Toe (Hard Version)
- leetcode37 解數獨問題 hardLeetCode
- C135 線段樹分治 P5631 最小mex生成樹
- Tower 最新註冊碼 Tower 破解下載
- git reset --hard 操作後的資料恢復Git資料恢復
- P6123 [NEERC2016] Hard Refactoring 題解
- CF1998E2 Eliminating Balls With Merging (Hard Version)
- 密碼學系列之:memory-hard函式密碼學函式
- 【LeetCode】493. Reverse Pairs 翻轉對(Hard)(JAVA)LeetCodeAIJava
- Tower 最新啟用版附Tower 破解金鑰