This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
int k;
int arr1[]{8,13,16,32,53,64,73,82,91,100};
int arr2[]{3,4,4,5,6,6,7,7,7,7};
void solve(int depth)
{
if(depth==1)
{
for(int i=1;i+1<=1<<k;i+=2)
{
if(i+1<=n)
{
printf("CMPSWP R%d R%d ",i,i+1);
}
}
printf("\n");
return;
}
solve(depth-1);
for(int i=1;i<=1<<k;i++)
{
if((i-1)%(1<<depth)<1<<(depth-1) && i<=n && i+(1<<depth)-2*((i-1)%(1<<depth))-1<=n)
{
printf("CMPSWP R%d R%d ",i,i+(1<<depth)-2*((i-1)%(1<<depth))-1);
}
}
printf("\n");
for(int i=depth-1;i>0;i--)
{
for(int j=1;j<=1<<k;j++)
{
if((j-1)%(1<<i)<1<<(i-1) && j<=n && j+(1<<(i-1))<=n)
{
printf("CMPSWP R%d R%d ",j,j+(1<<(i-1)));
}
}
printf("\n");
}
}
int main()
{
scanf("%d",&n);
for(int i=0;i<10;i++)
{
if(arr1[i]==n)
{
k=arr2[i];
}
}
printf("%d\n",k*(k+1)/2);
solve(k);
}
Compilation message (stderr)
malnarisc.cpp: In function 'int main()':
malnarisc.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
55 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |