QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#249815 | #6309. Aqre | tpc_icpc_n# | WA | 1ms | 3868kb | C++20 | 3.1kb | 2023-11-12 16:09:40 | 2023-11-12 16:09:41 |
Judging History
answer
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define rep(i,n) for (int i = 0; i < (n); i++)
#ifdef LOCAL
#define show(x) cerr << #x << " = " << x << endl;
#else
#define show(x) true
#endif
template<class T> ostream &operator<<(ostream &os, vector<T> &v) {
os << "[ ";
for (auto& e : v) os << e << ", ";
return os << " ]";
}
void solve() {
int N,M; cin >> N >> M;
if(N<=3 && M<=3){
cout << N*M << '\n';
rep(i,N) cout << string(M,'1') << '\n';
}
else if(N<=3){
string bs(M,'1');
int cnt = N*M;
vector<string> A(N,bs);
rep(i,N){
for(int j=((i%2==0)?3:1);j<M;j+=4){
A[i][j] = '0';
cnt--;
}
}
cout << cnt << '\n';
rep(i,N) cout << A[i] << '\n';
}
else if(M<=3){
vector<string> bs = {"111","101","111","010"};
vector<int> mn = {0,1,0,2};
int cnt = N*M;
vector<string> A(N);
rep(i,N){
A[i] = bs[i%4];
cnt -= mn[i%4];
}
cout << cnt << '\n';
rep(i,N) cout << A[i] << '\n';
}
else{
int ans = 0;
vector<string> Ans;
vector<int> p = {0,2,1,3,0,2,1};
rep(i,4){
int cnt = N*M;
string bs(M,'1');
vector<string> A(N,bs);
for(int y=0;y<N;y++){
for(int j=p[i+y%4];j<M;j+=4){
A[y][j] = '0';
cnt--;
}
}
if(A[0][0]=='1' && A[0][1]=='0' && A[1][0]=='0'){
A[0][0] = '0';
cnt--;
}
if(A[0][M-1]=='1' && A[0][M-1-1]=='0' && A[1][M-1]=='0'){
A[0][M-1] = '0';
cnt--;
}
if(A[N-1][0]=='1' && A[N-1][1]=='0' && A[N-1-1][0]=='0'){
A[N-1][0] = '0';
cnt--;
}
if(A[N-1][M-1]=='1' && A[N-1][M-1-1]=='0' && A[N-1-1][M-1]=='0'){
A[N-1][M-1] = '0';
cnt--;
}
if(ans < cnt){
ans = cnt;
Ans = A;
}
}
cout << ans << '\n';
rep(i,N) cout << Ans[i] << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1; cin >> T;
while (T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3868kb
input:
3 2 2 3 4 3 8
output:
4 11 11 9 1110 1011 1110 18 11101110 10111011 11101110
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3656kb
input:
361 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 1...
output:
4 11 11 6 111 111 6 1110 1011 8 11101 10111 9 111011 101110 11 1110111 1011101 12 11101110 10111011 14 111011101 101110111 15 1110111011 1011101110 17 11101110111 10111011101 18 111011101110 101110111011 20 1110111011101 1011101110111 21 11101110111011 10111011101110 23 111011101110111 1011101110111...
result:
wrong answer Length must be equal to m (test case 39)