QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#506643 | #7637. Exactly Three Neighbors | pandapythoner# | WA | 0ms | 3784kb | C++23 | 4.1kb | 2024-08-05 20:23:48 | 2024-08-05 20:23:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, n) for(int i = 0; i < n; i += 1)
#define len(a) ((int)(a).size())
const ll inf = 1e18;
mt19937 rnd(234);
int32_t main() {
vector<pair<int, int>> a;
for (int p = 1; p <= 10; p += 1) {
for (int q = p; q <= 10; q += 1) {
if (gcd(p, q) == 1) {
a.push_back(make_pair(p, q));
}
}
}
if (0) {
sort(all(a), [&](const pair<int, int>& x, const pair<int, int>& y) {
return x.first * y.second < x.second * y.first;
});
for (auto [p, q] : a) {
// cerr << p << " " << q << "\n";
}
for (int n = 1; n <= 10; n += 1) {
for (int m = 1; m <= 10 and m * n <= 25; m += 1) {
for (int mask = 0; mask <= (1 << (m * n)); mask += 1) {
int cnt = 0;
rep(i, m * n) cnt += ((mask >> i) & 1);
int p = cnt;
int q = m * n;
int g = gcd(p, q);
p /= g;
q /= g;
bool ok = true;
auto get = [&](int i, int j) {
if (i < 0) i += n;
if (i >= n) i -= n;
if (j < 0) j += m;
if (j >= m) j -= m;
return ((mask >> (i * m + j)) & 1);
};
rep(i, n) rep(j, m) {
if (!get(i, j)) continue;
if (get(i + 1, j) + get(i - 1, j) + get(i, j + 1) + get(i, j - 1) != 3) {
ok = false;
break;
}
}
if (!ok) {
continue;
}
if (p == 3 and q == 4) {
cerr << "Found!" << "\n";
cout << "cout << " << n << " << " << m << " << \"\\n\";\n";
rep(i, n) {
cout << "cout << \"";
rep(j, m) cout << (get(i, j) ? '#' : '.');
cout << "\";\n";
}
return 0;
}
}
}
}
}
if (1) {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int p, q;
cin >> p >> q;
assert(q != 0);
if (p == q) {
cout << -1 << " " << -1 << "\n";
return 0;
}
if (p == 0) {
cout << 1 << " " << 1 << "\n";
cout << '.' << "\n";
return 0;
}
if (3 * p <= 2 * q) {
int b = 2 * p;
int w = 2 * (q - p);
vector<int> buckets(b / 2);
int i = 0;
rep(cnt, w) {
buckets[i] += 1;
i = (i + 1) % (b / 2);
}
cout << 1 << " " << b + w << "\n";
rep(i, b / 2) {
cout << "##";
assert(buckets[i] > 0);
rep(k, buckets[i]) cout << ".";
}
cout << "\n";
return 0;
}
if (5 * p == 4 * q) {
cout << 5 << " " << 5 << "\n";
rep(i, 5) {
rep(j, 5) {
if ((2 * i + j) % 5 == 0) {
cout << '.';
} else {
cout << '#';
}
}
cout << "\n";
}
return 0;
}
if (p == 7 and q == 10) {
cout << 4 << " " << 5 << "\n";
cout << "#.###" << "\n";
cout << "#.###" << "\n";
cout << "###.." << "\n";
cout << "###.." << "\n";
return 0;
}
if (p == 3 and q == 4) {
cout << 4 << " " << 4 << "\n";
cout << "####" << "\n";
cout << "..##" << "\n";
cout << "####" << "\n";
cout << "##.." << "\n";
return 0;
}
cout << -1 << " " << -1 << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
2 3
output:
1 6 ##.##.
result:
ok good solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
1 1
output:
-1 -1
result:
ok no solution
Test #3:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
3 4
output:
4 4 #### ..## #### ##..
result:
ok good solution
Test #4:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
3 5
output:
1 10 ##..##.##.
result:
ok good solution
Test #5:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
4 5
output:
5 5 .#### ###.# #.### ####. ##.##
result:
ok good solution
Test #6:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
7 10
output:
4 5 #.### #.### ###.. ###..
result:
ok good solution
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
5 7
output:
-1 -1
result:
wrong answer you didn't find a solution but jury did