結果
| 問題 |
No.490 yukiソート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-18 14:29:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 479 bytes |
| コンパイル時間 | 593 ms |
| コンパイル使用メモリ | 51,256 KB |
| 最終ジャッジ日時 | 2024-11-14 20:04:44 |
| 合計ジャッジ時間 | 1,290 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:3: error: ‘vector’ was not declared in this scope
7 | vector<int> a(n, 0); // a[n]
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:7:10: error: expected primary-expression before ‘int’
7 | vector<int> a(n, 0); // a[n]
| ^~~
main.cpp:9:18: error: ‘a’ was not declared in this scope
9 | scanf("%d", &a[i]);
| ^
main.cpp:14:31: error: ‘a’ was not declared in this scope
14 | if(p < q && q <= n-1 && a[p] > a[q]) {
| ^
main.cpp:21:18: error: ‘a’ was not declared in this scope
21 | printf("%d", a[i]);
| ^
main.cpp:6:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | int n; scanf("%d", &n);
| ~~~~~^~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
int n; scanf("%d", &n);
vector<int> a(n, 0); // a[n]
for(int i=0; i<n; ++i) {
scanf("%d", &a[i]);
}
for(int i=1; i<2*n-3; ++i) {
for(int p=0; p<n-1; ++p) {
int q = i - p;
if(p < q && q <= n-1 && a[p] > a[q]) {
swap(a[p], a[q]);
}
}
}
for(int i=0; i<n; ++i) {
if(i) { putchar(' '); }
printf("%d", a[i]);
}
putchar('\n');
return 0;
}