/*
手玩資料找規律
你會發現有很強的規律性
*/
// O(n)
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int n, m;
string s;
int x[3] = {2, 1, 0};
int y[3] = {2, 0, 1};
int x2[3] = {1, 0, 2};
int y2[3] = {0, 1, 2};
int main()
{
int T;
cin >> T;
while (T -- )
{
cin >> n;
s.clear();
if (n == 1) cout << '2';
else if (n == 2) cout << "0 1";
else
{
if ((n & 1) == 0)
{
n -= 2;
string s2, s3;
for (int i = 0; i < n; i += 2)
{
s2 += x[i % 3] + '0';
s3 += y[i % 3] + '0';
}
reverse(s2.begin(), s2.end());
s += s2;
s += "01";
s += s3;
}
else
{
n -- ;
n /= 2;
string s2, s3;
for (int i = 0; i < n; i ++ )
{
s2 += x2[i % 3] + '0';
s3 += y2[i % 3] + '0';
}
// cout << s2 << endl;
reverse(s2.begin(), s2.end());
// cout << s2 << s3 << endl;
s += s2;
s += "2";
s += s3;
}
for (int i = 0; s[i]; i ++ ) cout << s[i] << ' ';
}
puts("");
}
return 0;
}
/*
// O(n^2)
#include <algorithm>
#include <cstring>
#include <iostream>
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, s3;
if (s1.compare("2") == 0) return (string)"01";
int len = s1.size() - 1;
for (int i = 0; i < len; i ++ )
{
s2 += get(s1[i], s1[i + 1]);
}
s3 += get(s1[0], s2[0]);
s3 += s2;
s3 += get(s2[len - 1], s1[len]);
return s3;
}
int main()
{
int T;
cin >> T;
while (T -- )
{
cin >> n;
s.clear();
if (n == 1) cout << '2';
else if (n == 2) cout << "0 1";
else
{
s = "01";
n -= 2;
while (n -- ) s = make(s);
for (int i = 0; s[i]; i ++ ) cout << s[i] << ' ' ;
}
puts("");
}
return 0;
}
*/
T429423 「LAOI-4」Mex Tower (Easy ver.)
相關文章
- T434199 「LAOI-4」Mex Tower (Hard ver.)
- C. MEX Game 1GAM
- T422088 「LAOI-4」Colors
- ABC 308E MEX
- Matlab以MEX方式呼叫C原始碼Matlab原始碼
- CF1905D Cyclic MEX 題解
- CF1744F MEX vs MED 題解
- 並查集解mex_cf932_B. Informatics in MAC並查集ORMMac
- 字串魔法(easy)字串
- ACM A problem is easyACM
- 【BUUCTF】easy calc
- 【BUUCTF】Easy JavaJava
- 【PR #12】劃分序列 / Yet Another Mex Problem 題解
- Easy-Admin
- vue-easy-rendererVue
- type challenge(easy 部分)
- Prefix Flip (Easy Version)
- Catch the Mole(Easy Version)
- P11059 [入門賽 #27] 數字 (Hard Ver.)題解
- j-easy/easy-rules: Java簡單的規則引擎Java
- matlab中出現mex無法編譯的問題Matlab編譯
- Tower 最新註冊碼 Tower 破解下載
- Easy-locust Web 版本Web
- LeetCode-EasyLeetCode
- 精讀《type challenges - easy》
- Leetcode(easy heap)LeetCode
- ES-Client-easy esclient
- 攻防世界-Easy_ECC
- 攻防世界-easy_RSA
- Tower 最新啟用版附Tower 破解金鑰
- iframeWin For Easy UI. 為 Easy UI 擴充套件的支援IFrame外掛UI套件
- 巴別塔(Tower of Babel)Babel
- Java規則引擎 Easy RulesJava
- Tower金鑰啟用安裝包「Tower破解下載」
- An easy guide to object rest/spreadGUIIDEObjectREST
- windows本地安裝部署 Easy MockWindowsMock
- 搭建Easy UI開發環境UI開發環境
- 【leetcode】length of last word (easy)LeetCodeAST