QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#218535#6743. water235curtain_cppWA 0ms3704kbC++142.8kb2023-10-18 14:40:522023-10-18 14:40:52

Judging History

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

  • [2023-10-18 14:40:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2023-10-18 14:40:52]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
using namespace std;
typedef long long  LL;
typedef unsigned long long uLL;
typedef pair<LL,LL> PII;
const int N = 2e5+10;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1);
#define debug(x) cout<<"[debug]"#x<<"="<<x<<'\n';
template <int T>
struct ModInt {
    const static int MD = T;
    int x;
    ModInt(LL x = 0)
        : x(x % MD) {}
    int get() { return x; }
    ModInt operator+(const ModInt& that) const {
        int x0 = x + that.x;
        return ModInt(x0 < MD ? x0 : x0 - MD);
    }
    ModInt operator-(const ModInt& that) const {
        int x0 = x - that.x;
        return ModInt(x0 < MD ? x0 + MD : x0);
    }
    ModInt operator*(const ModInt& that) const {
        return ModInt((long long)x * that.x % MD);
    }
    ModInt operator/(const ModInt& that) const {
        return *this * that.inverse();
    }
    void operator+=(const ModInt& that) {
        x += that.x;
        if (x >= MD)
            x -= MD;
    }
    void operator-=(const ModInt& that) {
        x -= that.x;
        if (x < 0)
            x += MD;
    }
    void operator*=(const ModInt& that) { x = (long long)x * that.x % MD; }
    void operator/=(const ModInt& that) { *this = *this / that; }
    ModInt inverse() const {
        int a = x, b = MD, u = 1, v = 0;
        while (b) {
            int t = a / b;
            a -= t * b;
            std::swap(a, b);
            u -= t * v;
            std::swap(u, v);
        }
        if (u < 0)
            u += MD;
        return u;
    }
    friend ostream& operator<<(ostream& os, ModInt x) {
        os << x.get();
        return os;
    }
};//全局变量记得清零!
const int mod=998244353;
typedef ModInt<mod> mint;
LL gcd(LL a, LL b)
{
   return b ? gcd(b, a % b) : a;
}
void solve()
{
   int n,m;cin>>n>>m;
   int mp[n][m];
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          mp[i][j]=0;
      }

   }
   for(int i=0;i<n;i++){
       for(int j=0;j<m;j++){
          if(i==j) mp[i][j]=1;
       }
   }
   int cnt=0;
    if(n>m){
           for(int i=m;i<n;i++) {
               if((i-m)%2==0){
                     mp[i][m-1]=1;
               }
           }
          }else if(n<m){
             for(int i=n;i<m;i++){
                 if((i-n)%2==0){
                     mp[n-1][i]=1;
                 }
             }
          }
          cout<<min(n,m)+(abs(n-m)+1)/2+(abs(n-m)%2==0&&n-m>0)<<'\n';
   for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          cout<<mp[i][j]<<" ";
      }
      cout<<'\n';
   }
}
int main()
{
   ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
   solve();
}

詳細信息

Test #1:

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

input:

2 1

output:

2
1 
1 

result:

ok The answer is correct.

Test #2:

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

input:

3 3

output:

3
1 0 0 
0 1 0 
0 0 1 

result:

ok The answer is correct.

Test #3:

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

input:

1 4

output:

3
1 1 0 1 

result:

ok The answer is correct.

Test #4:

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

input:

2 2

output:

2
1 0 
0 1 

result:

ok The answer is correct.

Test #5:

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

input:

2 4

output:

3
1 0 0 0 
0 1 1 0 

result:

wrong answer The answer is wrong: empty blocks exist