2 条题解
-
1
#include <bits/stdc++.h> using namespace std; const int maxn = 20000 + 10; int a[maxn], b[maxn]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } bool visited[5001] = {false}; int cnt = 0; for (int i = 0; i < n; i++) { if (!visited[a[i]]) { visited[a[i]] = true; b[cnt++] = a[i]; } } for (int i = 0; i < cnt; i++) { cout << b[i] << " "; } cout << endl; return 0; } -
1
#include <bits/stdc++.h> using namespace std; const int maxn = 20000 + 10; int a[maxn], b[maxn]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } bool visited[5001] = {false}; int cnt = 0; for (int i = 0; i < n; i++) { if (!visited[a[i]]) { visited[a[i]] = true; b[cnt++] = a[i]; } } for (int i = 0; i < cnt; i++) { cout << b[i] << " "; } cout << endl; return 0; }
- 1
信息
- ID
- 330
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 3
- 标签
- 递交数
- 193
- 已通过
- 94
- 上传者