QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302680#7178. BishopsivazivaWA 1ms3532kbC++142.9kb2024-01-11 06:13:152024-01-11 06:13:15

Judging History

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

  • [2024-01-11 06:13:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3532kb
  • [2024-01-11 06:13:15]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;
    cin>>n>>m;
    if (n==m)
    {
        cout<<n+m-2<<endl;
        for (long long i=1;i<=n;i++) cout<<1<<" "<<i<<endl;
        for (long long i=2;i<=n-1;i++) cout<<n<<" "<<i<<endl;
        return 0;
    }
    if (n<m)
    {
        if (n%2==1)
        {
            cout<<n+m-1<<endl;
            for (long long i=1;i<=n;i++) cout<<i<<" "<<1<<endl;
            for (long long i=1;i<=n;i++) cout<<i<<" "<<m<<endl;
            long long sredina=(n+1)/2;
            for (long long i=sredina+1;i<=m-sredina;i++) cout<<sredina<<" "<<i<<endl;
            return 0;
        }
        if (m%2==1)
        {
            cout<<n+m-1<<endl;
            for (long long i=1;i<=n;i++) cout<<i<<" "<<1<<endl;
            for (long long i=1;i<=n;i++) cout<<i<<" "<<m<<endl;
            long long sredina1=n/2;
            long long sredina2=sredina1+1;
            for (long long i=sredina2;i<=m-sredina2;i+=2) cout<<sredina1<<" "<<i<<endl;
            for (long long i=sredina2;i<=m-sredina2;i+=2) cout<<sredina2<<" "<<i<<endl;
        }
        else
        {
            cout<<n+m-2<<endl;m--;
            for (long long i=1;i<=n;i++) cout<<i<<" "<<1<<endl;
            for (long long i=1;i<=n;i++) cout<<i<<" "<<m<<endl;
            long long sredina1=n/2;
            long long sredina2=sredina1+1;
            for (long long i=sredina2;i<=m-sredina2;i+=2) cout<<sredina1<<" "<<i<<endl;
            for (long long i=sredina2;i<=m-sredina2;i+=2) cout<<sredina2<<" "<<i<<endl;
        }
    }
    else
    {
        if (m%2==1)
        {
            cout<<n+m-1<<endl;
            for (long long i=1;i<=m;i++) cout<<1<<" "<<i<<endl;
            for (long long i=1;i<=m;i++) cout<<n<<" "<<i<<endl;
            long long sredina=(m+1)/2;
            for (long long i=sredina+1;i<=n-sredina;i++) cout<<i<<" "<<sredina<<endl;
            return 0;
        }
        if (n%2==1)
        {
            cout<<n+m-1<<endl;
            for (long long i=1;i<=m;i++) cout<<1<<" "<<i<<endl;
            for (long long i=1;i<=m;i++) cout<<n<<" "<<i<<endl;
            long long sredina1=m/2;
            long long sredina2=sredina1+1;
            for (long long i=sredina2;i<=n-sredina2;i+=2) cout<<i<<" "<<sredina1<<endl;
            for (long long i=sredina2;i<=n-sredina2;i+=2) cout<<i<<" "<<sredina2<<endl;
        }
        else
        {
            cout<<n+m-2<<endl;n--;
            for (long long i=1;i<=m;i++) cout<<1<<" "<<i<<endl;
            for (long long i=1;i<=m;i++) cout<<n<<" "<<i<<endl;
            long long sredina1=m/2;
            long long sredina2=sredina1+1;
            for (long long i=sredina2;i<=n-sredina2;i+=2) cout<<i<<" "<<sredina1<<endl;
            for (long long i=sredina2;i<=n-sredina2;i+=2) cout<<i<<" "<<sredina2<<endl;
        }
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3532kb

input:

2 5

output:

6
1 1
2 1
1 5
2 5
1 2
2 2

result:

wrong answer Sum diagonals are not distinct