QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#230819 | #7637. Exactly Three Neighbors | ucup-team191# | AC ✓ | 0ms | 3840kb | C++14 | 3.4kb | 2023-10-28 20:59:50 | 2023-10-28 20:59:54 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using pii=pair<int,int>;
using vi=vector<int>;
using ll=long long;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)
const int N=300010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;
int n, m;
void dva_puta_k (int k) {
int g = __gcd(k + 2, 2 * k + 2);
//cout << "omjer " << (k + 2) / g << " " << (2 * k + 2) / g << endl;
cout << 4 << " " << 2 * (k + 1) << endl;
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 2 * k + 2; i++) {
if (i < k) cout << "."; else cout << "#";
}
cout << endl;
}
for (int j = 0; j < 2; j++) {
for (int i = 0; i < k + 1; i++) cout << "#";
for (int i = 0; i < k; i++) cout << ".";
cout << "#" << endl;
}
}
void jedan_puta_k (int k) {
int g = __gcd(2 * k + 2, 3 * k + 2);
//cout << "omjer " << (2 * k + 2) / g << " " << (3 * k + 2) / g << endl;
int korak;
int poc = 1;
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 3 * k + 2; j++) {
int dif = (j - poc + 3 * k + 2) % (3 * k + 2);
}
poc = (poc + 2 * k + 1) % (3 * k + 2);
if (poc == 1) {
korak = i + 1;
break;
}
}
cout << korak << " " << 3 * k + 2 << endl;
poc = 1;
for (int i = 0; i < korak; i++) {
for (int j = 0; j < 3 * k + 2; j++) {
int dif = (j - poc + 3 * k + 2) % (3 * k + 2);
if (dif < k) cout << "."; else cout << "#";
}
poc = (poc + 2 * k + 1) % (3 * k + 2);
cout << endl;
}
}
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
if (n == 0) {
cout << "1 1" << endl;
cout << "." << endl;
} else if (n * 5 > 4 * m) {
cout << -1 << " " << -1 << endl;
} else if (n == 1 || n == 2) {
if (n == 1) {
n *= 2;
m *= 2;
}
cout << 1 << " " << m << endl;
for (int i = 0; i < m; i++) {
if (i < 2) cout << "#"; else cout << ".";
}
cout << endl;
} else if (n == 4 && m == 7) {
cout << 1 << " " << m << endl;
cout << "##.##.." << endl;
} else if (n == 4 && m == 9) {
cout << 1 << " " << m << endl;
cout << "##.##...." << endl;
} else if (n == 3 && m == 4) {
dva_puta_k(1);
} else if (n == 5 && m == 8) {
dva_puta_k(3);
} else if (n == 3 && m == 5) {
dva_puta_k(4);
} else if (n == 5 && m == 9) {
dva_puta_k(8);
} else if (n == 4 && m == 5) {
jedan_puta_k(1);
} else if (n == 5 && m == 7) {
jedan_puta_k(4);
} else if (n == 7 && m == 10) {
jedan_puta_k(6);
} else if (n == 3 && m == 7) {
cout << 1 << " " << 14 << endl;
cout << "##.##.##......" << endl;
} else if (n == 3 && m == 8) {
cout << 1 << " " << 16 << endl;
cout << "##.##.##........" << endl;
} else if (n == 3 && m == 10) {
cout << 1 << " " << 20 << endl;
cout << "##.##.##............" << endl;
} else if (n == 7 && m == 9) {
vector < string > v(6, string(18, '#'));
v[0][1] = '.'; v[0][6] = '.'; v[0][9] = '.'; v[0][14] = '.';
v[1][3] = '.'; v[1][6] = '.'; v[1][11] = '.'; v[1][16] = '.';
v[2][0] = '.'; v[2][3] = '.'; v[2][8] = '.'; v[2][13] = '.';
v[3][0] = '.'; v[3][5] = '.'; v[3][10] = '.'; v[3][15] = '.';
v[4][2] = '.'; v[4][7] = '.'; v[4][12] = '.'; v[4][15] = '.';
v[5][4] = '.'; v[5][9] = '.'; v[5][12] = '.'; v[5][17] = '.';
cout << 6 << " " << 18 << endl;
for(auto ss : v) cout << ss << endl;
} else {
assert(0);
cout << "-1 -1" << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
2 3
output:
1 3 ##.
result:
ok good solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
1 1
output:
-1 -1
result:
ok no solution
Test #3:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
3 4
output:
4 4 .### .### ##.# ##.#
result:
ok good solution
Test #4:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
3 5
output:
4 10 ....###### ....###### #####....# #####....#
result:
ok good solution
Test #5:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
4 5
output:
5 5 #.### ####. ##.## .#### ###.#
result:
ok good solution
Test #6:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
7 10
output:
20 20 #......############# ##############...... #######......####### ......############## #############......# ######......######## .....##############. ############......## #####......######### ....##############.. ###########......### ####......########## ...##############... ##########......#### ...
result:
ok good solution
Test #7:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5 7
output:
14 14 #....######### ##########.... #####....##### ....########## #########....# ####....###### ...##########. ########....## ###....####### ..##########.. #######....### ##....######## .##########... ######....####
result:
ok good solution
Test #8:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
7 9
output:
6 18 #.####.##.####.### ###.##.####.####.# .##.####.####.#### .####.####.####.## ##.####.####.##.## ####.####.##.####.
result:
ok good solution
Test #9:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
0 1
output:
1 1 .
result:
ok good solution
Test #10:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
1 2
output:
1 4 ##..
result:
ok good solution
Test #11:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
1 3
output:
1 6 ##....
result:
ok good solution
Test #12:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
1 4
output:
1 8 ##......
result:
ok good solution
Test #13:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
1 5
output:
1 10 ##........
result:
ok good solution
Test #14:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
1 6
output:
1 12 ##..........
result:
ok good solution
Test #15:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1 7
output:
1 14 ##............
result:
ok good solution
Test #16:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1 8
output:
1 16 ##..............
result:
ok good solution
Test #17:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
1 9
output:
1 18 ##................
result:
ok good solution
Test #18:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
1 10
output:
1 20 ##..................
result:
ok good solution
Test #19:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
2 5
output:
1 5 ##...
result:
ok good solution
Test #20:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
2 7
output:
1 7 ##.....
result:
ok good solution
Test #21:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 9
output:
1 9 ##.......
result:
ok good solution
Test #22:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
3 7
output:
1 14 ##.##.##......
result:
ok good solution
Test #23:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
3 8
output:
1 16 ##.##.##........
result:
ok good solution
Test #24:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
3 10
output:
1 20 ##.##.##............
result:
ok good solution
Test #25:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
4 7
output:
1 7 ##.##..
result:
ok good solution
Test #26:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
4 9
output:
1 9 ##.##....
result:
ok good solution
Test #27:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
5 6
output:
-1 -1
result:
ok no solution
Test #28:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
5 8
output:
4 8 ...##### ...##### ####...# ####...#
result:
ok good solution
Test #29:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
5 9
output:
4 18 ........########## ........########## #########........# #########........#
result:
ok good solution
Test #30:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
6 7
output:
-1 -1
result:
ok no solution
Test #31:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
7 8
output:
-1 -1
result:
ok no solution
Test #32:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
8 9
output:
-1 -1
result:
ok no solution
Test #33:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
9 10
output:
-1 -1
result:
ok no solution
Extra Test:
score: 0
Extra Test Passed