Submission #1820644
Source Code Expand
#include<cstdio> #include<algorithm> using namespace std; int n, w[310], R[101000], RC; void Rotate(int K){ R[RC++] = K; for (int i = K; i < n; i++)swap(w[i - K], w[i]); } int main() { int i, j; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &w[i]); } for (i = 1; i < n; i++) { for (j = 0; j < n - i; j++) { if (w[0] < w[n - 1]) Rotate(n-1); Rotate(1); } for (j = 0; j < i - 1; j++)Rotate(1); if (i != n - 1)Rotate(1); } printf("%d\n", RC); for (i = 0; i < RC; i++)printf("%d\n", R[i]); }
Submission Info
Submission Time | |
---|---|
Task | B - Many Swaps Sorting |
User | ainta |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 546 Byte |
Status | AC |
Exec Time | 15 ms |
Memory | 512 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:11:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:13:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &w[i]); ^
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | 400 / 400 | 200 / 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 | 0 ms | 128 KB |
00_example_02.txt | AC | 1 ms | 128 KB |
s1_01.txt | AC | 1 ms | 128 KB |
s1_02.txt | AC | 0 ms | 128 KB |
s1_03.txt | AC | 0 ms | 128 KB |
s1_04.txt | AC | 0 ms | 128 KB |
s1_05.txt | AC | 1 ms | 128 KB |
s1_06.txt | AC | 0 ms | 128 KB |
s2_07.txt | AC | 1 ms | 128 KB |
s2_08.txt | AC | 1 ms | 128 KB |
s2_09.txt | AC | 1 ms | 128 KB |
s2_10.txt | AC | 1 ms | 128 KB |
s2_11.txt | AC | 1 ms | 128 KB |
s3_12.txt | AC | 3 ms | 256 KB |
s3_13.txt | AC | 6 ms | 384 KB |
s3_14.txt | AC | 2 ms | 256 KB |
s3_15.txt | AC | 1 ms | 256 KB |
s3_16.txt | AC | 15 ms | 512 KB |
s3_17.txt | AC | 14 ms | 512 KB |
s3_18.txt | AC | 14 ms | 512 KB |
s3_19.txt | AC | 15 ms | 512 KB |
s3_20.txt | AC | 13 ms | 384 KB |