1 solutions
-
2
swap(x,y)用来交换两个数的值
//我是奶龙 #include <bits/stdc++.h> using namespace std; int n, q, a[50005]; int main() { cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; while (q--) { int x, y; cin >> x >> y; swap(a[x], a[y]); } for (int i = 1; i <= n; i++) cout << a[i] << " "; return 0; }
- 1
Information
- ID
- 345
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 1
- Tags
- # Submissions
- 50
- Accepted
- 37
- Uploaded By