QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#233068 | #6743. water235 | dkdk | WA | 1ms | 3488kb | C++20 | 3.6kb | 2023-10-31 12:52:21 | 2023-10-31 12:52:21 |
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 = 1010, 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;
void solve()
{
int cnt = 0;
cin >> n >> m;
vector<int> w[n + 3];
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3456kb
input:
2 1
output:
2 1 1
result:
ok The answer is correct.
Test #2:
score: 0
Accepted
time: 1ms
memory: 3400kb
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: 3488kb
input:
1 4
output:
3 1 1 0 1
result:
ok The answer is correct.
Test #4:
score: 0
Accepted
time: 1ms
memory: 3384kb
input:
2 2
output:
2 1 0 0 1
result:
ok The answer is correct.
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3464kb
input:
2 4
output:
4 1 0 1 0 0 1 0 1
result:
wrong answer The answer is wrong: expected = 3, found = 4