Compile Error
foo.cc: In function 'int main()':
foo.cc:18:6: error: 'a' was not declared in this scope
18 | swap(a[n-1],a[n-2]);
| ^
foo.cc:23:2: error: expected '}' at end of input
23 | }
| ^
foo.cc:7:11: note: to match this '{'
7 | while(t--){
| ^
foo.cc:23:2: error: expected '}' at end of input
23 | }
| ^
foo.cc:4:11: note: to match this '{'
4 | int main(){
| ^
Code
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int> ans(n);
for(int i=0;i<n;i++)
ans[i]=i+1;
for(int i=0;i+1<n;i=i+2){
swap(ans[i],ans[i+1]);
if(n%2)
swap(a[n-1],a[n-2]);
for(auto c:ans)
cout<<c<<' ';
cout<<endl;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1210 A. Smallest Permutation
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-09-01 03:53:26
- Judged At
- 2025-09-01 03:53:26
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes