QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#412795#6743. water235Guren_WA 0ms3696kbC++204.6kb2024-05-16 19:36:212024-05-16 19:36:21

Judging History

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

  • [2024-05-16 19:36:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3696kb
  • [2024-05-16 19:36:21]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    if(n%2==1)
    {
       // cout<<n/3
       long long ans = 0;
       int flag1 = 0;
       for (int i = 1; i <= n;i++)
       {
        if(i%2==1&&flag1==0)
        {
            ans += n / 2 + 1;
            if (flag1 == 0)
                flag1 = 1;
            else
                flag1 = 0;
        }
        else if(i%2==1&&flag1==1)
        {
            ans += n / 2;
            if (flag1 == 0)
                flag1 = 1;
            else
                flag1 = 0;
        }
       
       }
       cout << ans << endl;
       int flag = 1;
       for (int i = 1; i <= n; i++)
       {
           if (i % 2 == 1)
           {
               if (flag == 1)
               {
                   for (int j = 1; j <= m; j++)
                   {
                       if (j % 2 == 1)
                       {
                           cout << "1 ";
                       }
                       else
                       {
                           cout << "0 ";
                       }
                   }
                   cout << endl;
               }
               if (flag == 0)
               {
                   for (int j = 1; j <= m; j++)
                   {
                       if (j % 2 == 0)
                       {
                           cout << "1 ";
                       }
                       else
                       {
                           cout << "0 ";
                       }
                   }
                   cout << endl;
               }
               if (flag == 1)
                   flag = 0;
               else
                   flag = 1;
           }

           else
           {
               for (int j = 1; j <= m; j++)
               {
                   cout << "0 ";
               }
               cout << endl;
           }
     
        }
    }
    else 
    {
        long long ans = 0;
        int flag1 = 0;
        for (int i = 1; i <= n; i++)
        {
            if(m%2==1)
            {
            if (i % 2 == 1 && flag1 == 0)
            {
                ans += n / 2 + 1;
                if (flag1 == 0)
                    flag1 = 1;
                else
                    flag1 = 0;
            }
            else if (i % 2 == 1 && flag1 == 1)
            {
                ans += n / 2;
                if (flag1 == 0)
                    flag1 = 1;
                else
                    flag1 = 0;
            }
            }
            else 
            {
            if (i % 2 == 1 && flag1 == 0)
            {
                ans += n / 2;
                if (flag1 == 0)
                    flag1 = 1;
                else
                    flag1 = 0;
            }
            else if (i % 2 == 1 && flag1 == 1)
            {
                ans += n / 2;
                if (flag1 == 0)
                    flag1 = 1;
                else
                    flag1 = 0;
            }
            }
        }
        cout << ans+1 << endl;
        int flag = 1;
        for (int i = 1; i <= n-1; i++)
        {
            if (i % 2 == 1)
            {
                if (flag == 1)
                {
                    for (int j = 1; j <= m; j++)
                    {
                        if (j % 2 == 1)
                        {
                            cout << "1 ";
                        }
                        else
                        {
                            cout << "0 ";
                        }
                    }
                    cout << endl;
                }
                if (flag == 0)
                {
                    for (int j = 1; j <= m; j++)
                    {
                        if (j % 2 == 0)
                        {
                            cout << "1 ";
                        }
                        else
                        {
                            cout << "0 ";
                        }
                    }
                    cout << endl;
                }
                if (flag == 1)
                    flag = 0;
                else
                    flag = 1;
            }

            else
            {
                for (int j = 1; j <= m; j++)
                {
                    cout << "0 ";
                }
                cout << endl;
            }
        }
        cout << "1 ";
        for (int i = 1; i <= m - 1;i++)
        {
            cout << "0 ";
        }
        cout << endl;
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3696kb

input:

2 1

output:

3
1 
1 

result:

wrong answer The answer is wrong: expected = 2, found = 3