Submission #1839180
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int MAXN = 205; int N; int p[MAXN]; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%d", p + i); vector <int> sol; while (1) { bool ok = true; for (int i = 1; i < N; i++) if (p[i - 1] > p[i]) { for (int j = 0; j < i; j++) sol.push_back(1); sol.push_back(N - 1); for (int j = 0; j < N - i; j++) sol.push_back(1); swap(p[i - 1], p[i]); ok = false; } if (ok) break; } printf("%d\n", sol.size()); for (auto it : sol) printf("%d\n", it); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Many Swaps Sorting |
User | abeker |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 614 Byte |
Status | WA |
Exec Time | 319 ms |
Memory | 23908 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:31:27: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<int>::size_type {aka long unsigned int}’ [-Wformat=] printf("%d\n", sol.size()); ^ ./Main.cpp:10:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:12:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", p + i); ^
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | 400 / 400 | 0 / 200 | ||||||||||
Status |
|
|
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
Subtask1 | 00_example_01.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt |
Subtask2 | 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s2_07.txt, s2_08.txt, s2_09.txt, s2_10.txt, s2_11.txt |
All | 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s2_07.txt, s2_08.txt, s2_09.txt, s2_10.txt, s2_11.txt, s3_12.txt, s3_13.txt, s3_14.txt, s3_15.txt, s3_16.txt, s3_17.txt, s3_18.txt, s3_19.txt, s3_20.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
s1_01.txt | AC | 1 ms | 256 KB |
s1_02.txt | AC | 1 ms | 256 KB |
s1_03.txt | AC | 1 ms | 256 KB |
s1_04.txt | AC | 1 ms | 256 KB |
s1_05.txt | AC | 1 ms | 256 KB |
s1_06.txt | AC | 1 ms | 256 KB |
s2_07.txt | AC | 1 ms | 256 KB |
s2_08.txt | AC | 1 ms | 256 KB |
s2_09.txt | AC | 2 ms | 256 KB |
s2_10.txt | AC | 2 ms | 384 KB |
s2_11.txt | AC | 2 ms | 384 KB |
s3_12.txt | WA | 23 ms | 2420 KB |
s3_13.txt | WA | 63 ms | 5104 KB |
s3_14.txt | WA | 10 ms | 1016 KB |
s3_15.txt | AC | 9 ms | 892 KB |
s3_16.txt | WA | 316 ms | 23652 KB |
s3_17.txt | WA | 177 ms | 18152 KB |
s3_18.txt | WA | 175 ms | 17128 KB |
s3_19.txt | WA | 319 ms | 23908 KB |
s3_20.txt | AC | 1 ms | 256 KB |