#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
int x, n; cin >> x >> n;
char ch; cin >> ch;
for (int i = 0; i < 1000; i++) cout << ch;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
int x; cin >> x;//诱惑值
int n; cin >> n;//个数
char maxch;
int maxw; cin >> maxch >> maxw;
for (int i = 1; i < n; i++) {
char ch; int w; cin >> ch >> w;
if (maxw < w) {
maxch = ch; maxw = w;
}
}
if (maxw * 1000 < x) {
cout << -1;
}
else {
for (int i = 0; i < 1000; i++) {
cout << maxch;
}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
string s[12];
int main() {
ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
cout << fixed << setprecision(12);
for (int i = 0; i < 5; i++) {
getline(cin, s[i]);
}
//与门 或门 非门
// 1-> 与门 & 1 1 出 1 其余出0
if (s[2][5] == '&') {
if (s[1][0] == s[3][0] && s[1][0] == '1') {
cout << 1;
}
else {
cout << 0;
}
}
// 2-> 或门 >= 1 只要有1出1 其余0
else if (s[2][5] == '=') {
if (s[1][0] == '1' || s[3][0] == '1') {
cout << 1;
}
else {
cout << 0;
}
}
// 3-> 非门 0 -> 1 or 1 -> 0
else {
if (s[2][0] == '0') {
cout << 1;
}
else {
cout << 0;
}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
cout << fixed << setprecision(12);
int T; cin >> T;
map<int, int> mp;
while (T--) {
int h, m; cin >> h >> m;
int sum = h * 60 + m;
mp[sum - 1] ++; mp[sum - 3]++; mp[sum - 5]++;
}
cout << mp.size() << '\n';
for (auto x : mp) {
cout << x.first / 60 << ' ' << x.first % 60 << '\n';
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10;
bool dp[N][N] = {true};
int main() {
ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
cout << fixed << setprecision(12);
int n, m; cin >> n >> m;
for (int i = 1, x; i <= m; i++) {
cin >> x; x %= n;
for (int j = 0; j < n; j++) {
dp[i][j] = dp[i - 1][(j - x + n) % n] | dp[i - 1][(j + x) % n];
}
}
cout << (dp[m][0] ? "YES\n" : "NO\n");
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
cout << fixed << setprecision(12);
int T; cin >> T;
while (T--) {
int n, m; cin >> n >> m;
vector<int> in(n), l(m), r(m);
map<int, int> fa;
for (int i = 0; i < n; i++) {
cin >> in[i];
}
for (int i = 0; i < m; i++) {
cin >> l[i] >> r[i];
}
for (int i = m - 1; i >= 0; i--) {
if (fa.count(r[i])) {
fa[l[i]] = fa[r[i]];
}
else {
fa[l[i]] = r[i];
}
}
for (int i = 0; i < n; i++) {
cout << (fa[in[i]] ? fa[in[i]] : in[i]) << ' ';
}
cout << '\n';
}
return 0;
}