/*
和上題一樣只不過,是換成了檢驗答案,還是找規律,
自己看看吧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.)題解
- C. MEX Game 1GAM
- T422088 「LAOI-4」Colors
- 《The Hard Thing About Hard Things》讀書筆記筆記
- ABC 308E MEX
- Reverse Card (Hard Version)
- First Missing Positive【hard】
- git reset --hard HEAD^Git
- Matlab以MEX方式呼叫C原始碼Matlab原始碼
- CF1905D Cyclic MEX 題解
- CF1744F MEX vs MED 題解
- Learning Django: the hard way (1)Django
- TSS文章:Hard Core ThreadLocalthread
- C2. Magnitude (Hard Version)
- C2. Potions (Hard Version)
- 並查集解mex_cf932_B. Informatics in MAC並查集ORMMac
- git程式碼回退--hard的坑Git
- D2. Reverse Card (Hard Version)
- D2. Set To Max (Hard Version)
- 【PR #12】劃分序列 / Yet Another Mex Problem 題解
- matlab中出現mex無法編譯的問題Matlab編譯
- 容斥定理 AtCoder——FizzBuzz Sum Hard
- leetcode:動態規劃( hard )LeetCode動態規劃
- soft parse(軟解析),hard parse(硬解析)
- Oracle ASM on Linux with single Hard DriveOracleASMLinux
- C2. Adjust The Presentation (Hard Version)
- Tower 最新註冊碼 Tower 破解下載
- Tower 最新啟用版附Tower 破解金鑰
- [AGC001E] BBQ Hard題解GC
- Trim your pubic hair hard times pills for saleAI
- fast parse,soft parse,hard parse的區別!AST
- [題解]CF958C3 Encryption (hard)
- 巴別塔(Tower of Babel)Babel
- 密碼學系列之:memory-hard函式密碼學函式
- Codeforces Global Round 11 C. The Hard Work of Paparazzi
- git reset --hard 操作後的資料恢復Git資料恢復
- Tower金鑰啟用安裝包「Tower破解下載」