1434A. Finding Sasuke

Codeforces Round #679 (Div. 2, based on Technocup 2021 Elimination Round 1) (个人题解) - 图1

  1. // Author : RioTian
  2. // Time : 20/10/25
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. typedef long long ll;
  6. ll _, n;
  7. void solve() {
  8. cin >> n;
  9. int a[n + 1];
  10. for (int i = 0; i < n; ++i) cin >> a[i];
  11. for (int i = 0; i < n; i += 2) cout << a[i + 1] << ' ' << -a[i] << ' ';
  12. cout << endl;
  13. }
  14. int main() {
  15. // freopen("in.txt", "r", stdin);
  16. ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  17. cin >> _;
  18. while (_--) solve();
  19. }

1435B. A New Technique

Codeforces Round #679 (Div. 2, based on Technocup 2021 Elimination Round 1) (个人题解) - 图2

  1. // Author : RioTian
  2. // Time : 20/10/25
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. typedef long long ll;
  6. const int N = 500 + 10;
  7. int T;
  8. int n, m, a[N][N], b[N][N], to[N * N];
  9. bool mark[N * N];
  10. int main(){
  11. ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  12. cin >> T;
  13. while (T--) {
  14. cin >> n >> m;
  15. for (int i = 0; i <= n * m; i++)
  16. mark[i] = to[i] = 0;
  17. for (int i = 0; i < n; i++) {
  18. for (int j = 0; j < m; j++)
  19. cin >> a[i][j];
  20. mark[a[i][0]] = 1;
  21. to[a[i][0]] = i;
  22. }
  23. for (int i = 0; i < m; i++)
  24. for (int j = 0; j < n; j++)
  25. cin >> b[i][j];
  26. for (int k = 0; k < m; k++)
  27. if (mark[b[k][0]]){
  28. for (int ii = 0; ii < n; ii++) {
  29. int i = to[b[k][ii]];
  30. for (int j = 0; j < m; j++) cout << a[i][j] << ' ';
  31. cout << '\n';
  32. }
  33. break;
  34. }
  35. }
  36. }