QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#84671 | #5528. Least Annoying Constructive Problem | johnsonloy_x | WA | 2ms | 3472kb | C++14 | 1.3kb | 2023-03-06 16:43:36 | 2023-03-06 16:45:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
const int maxn = 1e6+10;
namespace IO{
void openfile(){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
}
int add(int x,int y){
x+=y;
if(x>=mod)
x-=mod;
return x;
}
int sub(int x,int y){
x-=y;
if(x<0)
x+=mod;
return x;
}
inline int read(){
int x = 0,f = 0;
char c = getchar();
while(!isdigit(c))
f|=c=='-',c = getchar();
while(isdigit(c))
x = x*10+c-'0',c = getchar();
if(f)x = -x;
return x;
}
}
using namespace IO;
int n;
int vis[maxn];
int lst(int x){
x--;
if(!x)
x = n;
return x;
}
int nex(int x){
x++;
if(x>n)
x = 1;
return x;
}
void solve1(){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)
vis[j] = 0;
int l = lst(i),r = nex(i);
while(!vis[l])
printf("%d %d\n",l,r),vis[l] = vis[r] = 1,l = lst(l),r = nex(r);
}
}
void solve2(){
n--;
for(int i=1;i<=n;i++){
int l = i,r = nex(i);
while(l!=r)
printf("%d %d\n",l,r),l = lst(l),r = nex(r);
printf("%d %d\n",l,n+1);
}
}
signed main(){
// openfile();
n = read();
if(n&1)
solve1();
else solve2();
return 0;
}
//»¹Í¦nbµÄ¹¹ÔìÌâ
//¾ÍÊÇ°ÑÍêȫͼµÄÆ¥ÅäÄóöÀ´µ¥×ö
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3472kb
input:
3
output:
3 2 1 3 2 1
result:
wrong answer Integer 2 violates the range [4, 3]