--- tags: 蘿莉控自學 --- > 蘿莉控的C++自學筆記 # d547 北市賽 98 4-secret 連結:https://zerojudge.tw/ShowProblem?problemid=d547 不難的模擬題,但花時間 順暢使用會vector幫助很大 ```cpp= #include<bits/stdc++.h> using namespace std; vector <int> ans; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for(int i = 0;i < m;i ++){ int t; cin >> t; ans.push_back(t); } int len = m+1; for(int i = 0;i < n;i ++){ vector <int> tmp; vector <int> result; for(int j = 0;j < len;j ++){ int t; cin >> t; tmp.push_back(t); } int last = -1; for(int j = len - 1;j > 0;j --){ if (last == -1){ if (tmp[j] >= tmp[j-1]){ result.push_back(1); }else result.push_back(0); last = abs(tmp[j-1]-tmp[j]); continue; }else{ if (last >= tmp[j-1]) result.push_back(1); else result.push_back(0); last = abs(tmp[j-1]-tmp[j]); } } for(int j = 0;j < len;j ++){ if (j != len-j-1) swap(result[j], result[len-j-1]); } reverse(result.begin(), result.end()); bool check = true; for(int j = 0;j < len-1;j ++){ if (result[j] != ans[j]) check = false; } if (check){ for(int j = 0;j < len;j ++){ cout << tmp[j] <<" "; } } } } ```