QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350105#8215. Isomorphic Delightucup-team1525#WA 0ms3912kbC++171.2kb2024-03-10 14:22:542024-03-10 14:22:55

Judging History

你现在查看的是最新测评结果

  • [2024-03-10 14:22:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3912kb
  • [2024-03-10 14:22:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int n;
struct E{
    int u,v;
    E(int u=0,int v=0):u(u),v(v){}
};
vector<E> e;
void get(int x,int id){
    if(x==1) return;
    e.push_back(E(id,id+1));
    e.push_back(E(id,id+2));
    e.push_back(E(id+2,id+3));
    int u=id,v=id+4; x-=4;
    while(x){
        e.push_back(E(u,v));
        u=v; v=v+1;
        x--;
    }
}
int main(){
    scanf("%d",&n);
    if(n<=6){
        if(n==1){
            puts("YES");
            puts("0");
            return 0;
        }
        if(n<6){
            puts("NO");
            return 0;
        }
        if(n==6){
            puts("YES");
            puts("6");
            puts("1 2\n2 3\n1 3\n3 4\n2 5\n5 6");
            return 0;
        }
        return 0;
    }
    vector<int> p;
    int s=1,lst=1;
    for(int i=7;;i++){
        if(s+i<n){
            p.push_back(lst);
            lst=i;
            s+=i;
        }
        else{
            p.push_back(lst+n-s);
            break;
        }
    }
    puts("YES");
    for(int i=0,j=1;i<p.size();i++){
        get(p[i],j);
        j+=p[i];
    }
    printf("%d\n",e.size());
    for(auto it:e)
        printf("%d %d\n",it.u,it.v);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

input:

1

output:

YES
0

result:

ok Everything ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

6

output:

YES
6
1 2
2 3
1 3
3 4
2 5
5 6

result:

ok Everything ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

4

output:

NO

result:

ok Everything ok

Test #4:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

2

output:

NO

result:

ok Everything ok

Test #5:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

3

output:

NO

result:

ok Everything ok

Test #6:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

5

output:

NO

result:

ok Everything ok

Test #7:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

7

output:

YES
6
1 2
1 3
3 4
1 5
5 6
6 7

result:

ok Everything ok

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3752kb

input:

8

output:

YES
7
1 2
1 3
3 4
1 5
5 6
6 7
7 8

result:

wrong answer contestant's solution is worse (more edges) than jury's