QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#233087 | #6743. water235 | dkdk | WA | 6ms | 27112kb | C++20 | 3.6kb | 2023-10-31 13:06:11 | 2023-10-31 13:06:12 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <cmath>
#include <string>
#include <set>
#include <iomanip>
#define ft first
#define sd second
#define endl '\n'
#define lowbit(x) (x & (-x))
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PUU = pair<ULL, ULL>;
using PLL = pair<LL, LL>;
using i128 = __int128;
const double eps = 1e-9;
const int N = 1000010, mod = 80112002, INF = 2147483647;
int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
int qmi(int a, int b)
{
int res = 1, t = a;
while(b)
{
if(b & 1)res = (LL)res * t;
t = (LL)t * t;
b >>= 1;
}
return res;
}
int n, m;
vector<int> w[N];
void solve()
{
int cnt = 0;
cin >> n >> m;
for(int i = 0; i < n ; i++)
for(int j = 0; j < m ; j++)
w[i].push_back(0);
if(n == 1)
{
cout << m / 2 + 1 << endl;
if(m % 2 == 0)
{
for(int i = 0; i < m ; i++)
{
if(i == 0)cout << 1;
else if(i % 2)cout << 1;
else cout << 0;
if(i < m - 1)cout << ' ';
}
}
else
{
for(int i = 0; i < m ; i++)
{
if(i % 2 == 0)cout << 1;
else cout << 0;
if(i < m - 1)cout << ' ';
}
}
return;
}
if(m == 1)
{
cout << n / 2 + 1 << endl;
if(n % 2 == 0)
{
for(int i = 0; i < n ; i++)
{
if(i == 0)cout << 1;
else if(i % 2)cout << 1;
else cout << 0;
if(i < n - 1)cout << endl;
}
}
else
{
for(int i = 0; i < n ; i++)
{
if(i % 2 == 0)cout << 1;
else cout << 0;
if(i < n - 1)cout << endl;
}
}
return;
}
if(n == m)
{
cout << n << endl;
for(int i = 1; i <= n ; i++)
{
for(int j = 1; j <= m ; j++)
{
if(i == j)cout << 1;
else cout << 0;
if(j < m)cout << ' ';
}
if(i < n)cout << endl;
}
}
else if(n < m)
{
for(int i = 0; i < n ; i++)
for(int j = 0; j < m ; j++)
if(j % n == i)
w[i][j] = 1, cnt++;
cout << cnt << endl;
for(int i = 0; i < n ; i++)
{
for(int j = 0; j < m ; j++)
{
cout << w[i][j];
if(j < m - 1)cout << ' ';
}
if(i < n - 1)cout << endl;
}
}
else
{
for(int i = 0; i < n ; i++)
for(int j = 0; j < m ; j++)
if(i % m == j)
w[i][j] = 1, cnt++;
cout << cnt << endl;
for(int i = 0; i < n ; i++)
{
for(int j = 0; j < m ; j++)
{
cout << w[i][j];
if(j < m - 1)cout << ' ';
}
if(i < n - 1)cout << endl;
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
//cout << setprecision(20);
//init();
int T = 1;
//cin >> T;
while(T -- )solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 27040kb
input:
2 1
output:
2 1 1
result:
ok The answer is correct.
Test #2:
score: 0
Accepted
time: 3ms
memory: 27048kb
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: 3ms
memory: 27040kb
input:
1 4
output:
3 1 1 0 1
result:
ok The answer is correct.
Test #4:
score: 0
Accepted
time: 3ms
memory: 27104kb
input:
2 2
output:
2 1 0 0 1
result:
ok The answer is correct.
Test #5:
score: -100
Wrong Answer
time: 6ms
memory: 27112kb
input:
2 4
output:
4 1 0 1 0 0 1 0 1
result:
wrong answer The answer is wrong: expected = 3, found = 4