#include <bits/stdc++.h>
using namespace std;
int n,s,v[100005];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>s;
for(int i=1;i<=n;i++)
{
cin>>v[i];
}
if(s==1)
{
vector<pair<int,int>> rez;
for(int i=1;i<=n;i++)
{
int poz = i;
while(poz>1 && v[poz]<v[poz-1])
{
rez.push_back({poz,poz-1});
v[poz]^=v[poz-1];
rez.push_back({poz-1,poz});
v[poz-1]^=v[poz];
rez.push_back({poz,poz-1});
v[poz]^=v[poz-1];
--poz;
}
}
cout<<rez.size()<<'\n';
for(auto it : rez)
{
cout<<it.first<<' '<<it.second<<'\n';
}
return 0;
}
else
{
///meci mai cox
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
588 KB |
Output is correct |
5 |
Correct |
4 ms |
704 KB |
Output is correct |
6 |
Correct |
4 ms |
716 KB |
Output is correct |
7 |
Correct |
4 ms |
716 KB |
Output is correct |
8 |
Correct |
4 ms |
592 KB |
Output is correct |
9 |
Correct |
4 ms |
720 KB |
Output is correct |
10 |
Correct |
4 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
7 ms |
976 KB |
Output is correct |
13 |
Correct |
7 ms |
976 KB |
Output is correct |
14 |
Correct |
10 ms |
976 KB |
Output is correct |
15 |
Correct |
10 ms |
964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
588 KB |
Output is correct |
5 |
Correct |
4 ms |
704 KB |
Output is correct |
6 |
Correct |
4 ms |
716 KB |
Output is correct |
7 |
Correct |
4 ms |
716 KB |
Output is correct |
8 |
Correct |
4 ms |
592 KB |
Output is correct |
9 |
Correct |
4 ms |
720 KB |
Output is correct |
10 |
Correct |
4 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
7 ms |
976 KB |
Output is correct |
13 |
Correct |
7 ms |
976 KB |
Output is correct |
14 |
Correct |
10 ms |
976 KB |
Output is correct |
15 |
Correct |
10 ms |
964 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
4 ms |
716 KB |
Output is correct |
18 |
Correct |
6 ms |
836 KB |
Output is correct |
19 |
Correct |
6 ms |
848 KB |
Output is correct |
20 |
Correct |
6 ms |
848 KB |
Output is correct |
21 |
Correct |
7 ms |
848 KB |
Output is correct |
22 |
Correct |
7 ms |
876 KB |
Output is correct |
23 |
Correct |
6 ms |
852 KB |
Output is correct |
24 |
Correct |
6 ms |
852 KB |
Output is correct |
25 |
Correct |
6 ms |
852 KB |
Output is correct |
26 |
Incorrect |
12 ms |
1312 KB |
Integer 59568 violates the range [0, 40000] |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |