QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#249860 | #6309. Aqre | tpc_icpc_n# | WA | 1ms | 3612kb | C++20 | 3.5kb | 2023-11-12 16:59:06 | 2023-11-12 16:59:06 |
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++)
/*
bool BFS(vector<string> &s) {
return true;
int N = int(s.size()), M = int(s[0].size());
int sx, sy;
REP(i, N) REP(j, M) {
if (s[i][j] == '1') {
sx = i, sy = j;
}
}
queue<pair<int, int>> que;
que.push({sx, sy});
vector seen(N, vector<int>(M));
while (!que.empty()) {
auto [cx, cy] = que.
}
}
*/
void solve() {
int N,M; cin >> N >> M;
if(N==6 && M==6){
cout << 28 << '\n';
cout << "110111\n";
cout << "111011\n";
cout << "101110\n";
cout << "011101\n";
cout << "110111\n";
cout << "111011\n";
}
else 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-(M==2)};
int cnt = N*M;
vector<string> A(N);
rep(i,N){
A[i] = bs[i%4].substr(0,M);
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';
//assert(BFS(Ans));
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: 3612kb
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: 3552kb
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 ans finds a larger answer (test case 85)