QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#218542 | #6743. water235 | curtain_cpp | WA | 0ms | 3692kb | C++14 | 3.0kb | 2023-10-18 14:46:13 | 2023-10-18 14:46:13 |
Judging History
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(abs(n-m)%2==0){
if((i-m)&1){
mp[i][m-1]=1;
}
}else{
if((i-m)%2==0) mp[i][m-1]=1;
}
}
}else if(n<m){
for(int i=n;i<m;i++){
if(abs(n-m)%2==0){
if((i-n)&1){
mp[n-1][i]=1;
}
}else{
if((i-m)%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();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
2 1
output:
2 1 1
result:
ok The answer is correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
3 3
output:
3 1 0 0 0 1 0 0 0 1
result:
ok The answer is correct.
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3644kb
input:
1 4
output:
3 1 0 1 0
result:
wrong answer Invalid output