Code
#include<stdio.h>
int main() {
int n;
scanf("%d", &n);
for (int i=0; i<n; i++){
int x;
scanf("%d", &x);
// all ok above
int arr[x];
for (int k=1; k<=x; k++){
arr[k-1] = k;
}
// even works fin - no touch
for (int k=0; k+1<x; k+=2){
int tem = arr[k];
arr[k] = arr[k+1];
arr[k+1] = tem;
}
// odd - 2 1 3 >> 2 3 1
if (x%2!=0 && x >= 3){
int tem2 = arr[x-1];
arr[x-1] = arr[x-2];
arr[x-2] = tem2;
}
// work below
for (int fin=0; fin < x; fin++){
printf("%d ", arr[fin]);
}
// prints new line
printf("\n");
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1210 A. Smallest Permutation
- Contest
- Educational Round 1
- Language
- C99 (GCC 13.2.0)
- Submit At
- 2025-07-14 16:06:02
- Judged At
- 2025-07-14 16:06:02
- Judged By
- Score
- 100
- Total Time
- 1ms
- Peak Memory
- 284.0 KiB