Task: | Ruudukko |
Sender: | andreibe |
Submission time: | 2023-01-26 13:14:18 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 11 |
#2 | ACCEPTED | 25 |
#3 | ACCEPTED | 64 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#6 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#7 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#8 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#9 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#10 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#11 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#12 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#13 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#14 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#15 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#16 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
#17 | ACCEPTED | 0.01 s | 2, 3 | details |
#18 | ACCEPTED | 0.01 s | 2, 3 | details |
#19 | ACCEPTED | 0.01 s | 2, 3 | details |
#20 | ACCEPTED | 0.01 s | 2, 3 | details |
#21 | ACCEPTED | 0.01 s | 2, 3 | details |
#22 | ACCEPTED | 0.01 s | 2, 3 | details |
#23 | ACCEPTED | 0.01 s | 2, 3 | details |
#24 | ACCEPTED | 0.01 s | 2, 3 | details |
#25 | ACCEPTED | 0.07 s | 3 | details |
#26 | ACCEPTED | 0.07 s | 3 | details |
#27 | ACCEPTED | 0.07 s | 3 | details |
#28 | ACCEPTED | 0.07 s | 3 | details |
#29 | ACCEPTED | 0.07 s | 3 | details |
#30 | ACCEPTED | 0.07 s | 3 | details |
#31 | ACCEPTED | 0.07 s | 3 | details |
#32 | ACCEPTED | 0.07 s | 3 | details |
#33 | ACCEPTED | 0.07 s | 3 | details |
#34 | ACCEPTED | 0.07 s | 3 | details |
#35 | ACCEPTED | 0.07 s | 3 | details |
#36 | ACCEPTED | 0.07 s | 3 | details |
Compiler report
input/code.cpp: In function 'bool tarkistus(int, int)': input/code.cpp:91:1: warning: control reaches end of non-void function [-Wreturn-type] 91 | } | ^
Code
#include <iostream> #include <string> #include <math.h> #include <map> #include <algorithm> #include <vector> #include <fstream> #include <set> #include <unordered_map> #include <queue> #include <chrono> #include <climits> #include <stack> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace std::chrono; using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; #define S second #define F first //#define A 999999999999999999LL #define M 1000000007 #define N 202020 #define REDIR \ ifstream in("input.txt"); \ cin.rdbuf(in.rdbuf()); int d[1010][1010]; int z[1010][1010]; bool eiole(int y, int x, int n, int m) { if (y < 0 || x < 0 || y >= n || x >= m) { return true; } return d[y][x] ? false : true; } void print(int n, int m) { for (int y = 0; y < n; y++) { for (int x = 0; x < m; x++) { cout << (d[y][x] ? "#" : "."); } cout << endl; } } int syvyys(int y, int x, int y2, int x2, int n, int m) { if (y < 0 || x < 0 || y >= n || x >= m || d[y][x]) { return 0; } if (z[y][x]) return -99; z[y][x] = 1; int total = 1; if (y+1 != y2 || x != x2) total += syvyys(y+1,x, y,x,n,m); if (y-1 != y2 || x != x2) total += syvyys(y-1,x, y,x,n,m); if (y != y2 || x+1 != x2) total += syvyys(y,x+1, y,x,n,m); if (y != y2 || x-1 != x2) total += syvyys(y,x-1, y,x,n,m); return total; } bool tarkistus(int n, int m) { int total = 0; for (int y = 0; y < n; y++) { for (int x = 0; x < m; x++) { z[y][x] = 0; if (!d[y][x]) total++; } } for (int y = 0; y < n; y++) { for (int x = 0; x < m; x++) { if (!d[y][x]) { int maara = syvyys(y,x,-1,-1,n,m); //cout << maara << " vs " << total << endl; //print(); if (maara != total) return false; return true; } } } } void solve(int n, int m) { for (int y = 0; y < n; y++){ for (int x = 0; x < m; x++){ d[y][x] = 0; } } if (n == 1 || m == 1) { print(n,m); return; } int x = 1; bool leftStart = true; while (x < m) { bool left = leftStart; for (int y = 0; y < n-1; y++) { if (left) d[y][x] = 1; else if (x+1 != m-1 || (leftStart && y%4>1) || (!leftStart && y % 4>1))d[y][x+1] = 1; left = !left; } if (left) { d[n-1][x-1] = 1; } x += 3; leftStart = !leftStart; } if (!tarkistus(n,m)) { d[n-1][m-1] = 1; } print(n,m); //cout << tarkistus(n,m); } int main() { /* REDIR; vector<P> v = {{999,995}, {999,996}, {999,997}, {999,998}, {999,999}, {999,1000}, {1000,995}, {1000,996},{1000,997}, {1000,998}, {1000,998}}; for (P &p : v) { solve(p.first, p.second); } */ int n,m; cin >> n >> m; solve(n,m); //solve(n,m); //cout << tarkistus(n,m) << endl; //return 0; /* int eitoimi = 0; for (int korkeus = 1000; korkeus <= 1000; korkeus++) { for (int leveys = 1000; leveys <= 1000; leveys++) { solve(korkeus, leveys); if (!tarkistus(korkeus,leveys)) { d[korkeus-1][leveys-1] = 1; if (tarkistus(korkeus,leveys)) { cout << "Toimii: " << korkeus << " * " << leveys << endl; } else { eitoimi++; cout << "Ei toimi: " << korkeus << " * " << leveys << endl; print(korkeus,leveys); } } else { cout << "Toimii: " << korkeus << " * " << leveys << endl; } } } cout << eitoimi << endl; */ }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
1 1 |
correct output |
---|
. |
user output |
---|
. |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
1 2 |
correct output |
---|
.. |
user output |
---|
.. |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
1 3 |
correct output |
---|
... |
user output |
---|
... |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
1 4 |
correct output |
---|
.... |
user output |
---|
.... |
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
2 1 |
correct output |
---|
. . |
user output |
---|
. . |
Test 6
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
2 2 |
correct output |
---|
.# .. |
user output |
---|
.# .. |
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
2 3 |
correct output |
---|
.#. ... |
user output |
---|
.#. ... |
Test 8
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
2 4 |
correct output |
---|
.#.# .... |
user output |
---|
.#.. ...# |
Test 9
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 1 |
correct output |
---|
. . . |
user output |
---|
. . . |
Test 10
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 2 |
correct output |
---|
.# .. .# |
user output |
---|
.# .. #. |
Test 11
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 3 |
correct output |
---|
.#. ... .#. |
user output |
---|
.#. ... #.# |
Test 12
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 4 |
correct output |
---|
.#.# .... .#.# |
user output |
---|
.#.. ..#. #... |
Test 13
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
4 1 |
correct output |
---|
. . . . |
user output |
---|
. . . . |
Test 14
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
4 2 |
correct output |
---|
.. .# .. #. |
user output |
---|
.# .. .# .. |
Test 15
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
4 3 |
correct output |
---|
... .#. ..# #.. |
user output |
---|
.#. ... .#. ..# |
Test 16
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
4 4 |
correct output |
---|
.... .#.# ..#. #... |
user output |
---|
.#.. ..#. .#.. ...# |
Test 17
Group: 2, 3
Verdict: ACCEPTED
input |
---|
999 1 |
correct output |
---|
. . . . . ... |
user output |
---|
. . . . . ... Truncated |
Test 18
Group: 2, 3
Verdict: ACCEPTED
input |
---|
999 2 |
correct output |
---|
.# .. .# .. #. ... |
user output |
---|
.# .. .# .. .# ... Truncated |
Test 19
Group: 2, 3
Verdict: ACCEPTED
input |
---|
999 3 |
correct output |
---|
.#. ... .#. ..# #.. ... |
user output |
---|
.#. ... .#. ..# .#. ... Truncated |
Test 20
Group: 2, 3
Verdict: ACCEPTED
input |
---|
999 4 |
correct output |
---|
.#.# .... .#.# ..#. #... ... |
user output |
---|
.#.. ..#. .#.. ..#. .#.. ... Truncated |
Test 21
Group: 2, 3
Verdict: ACCEPTED
input |
---|
1000 1 |
correct output |
---|
. . . . . ... |
user output |
---|
. . . . . ... Truncated |
Test 22
Group: 2, 3
Verdict: ACCEPTED
input |
---|
1000 2 |
correct output |
---|
.. .# .. #. .. ... |
user output |
---|
.# .. .# .. .# ... Truncated |
Test 23
Group: 2, 3
Verdict: ACCEPTED
input |
---|
1000 3 |
correct output |
---|
... .#. ..# #.. ..# ... |
user output |
---|
.#. ... .#. ..# .#. ... Truncated |
Test 24
Group: 2, 3
Verdict: ACCEPTED
input |
---|
1000 4 |
correct output |
---|
.... .#.# ..#. #... ..#. ... |
user output |
---|
.#.. ..#. .#.. ..#. .#.. ... Truncated |
Test 25
Group: 3
Verdict: ACCEPTED
input |
---|
999 995 |
correct output |
---|
.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#... |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 26
Group: 3
Verdict: ACCEPTED
input |
---|
999 996 |
correct output |
---|
.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#... |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 27
Group: 3
Verdict: ACCEPTED
input |
---|
999 997 |
correct output |
---|
.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#... |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 28
Group: 3
Verdict: ACCEPTED
input |
---|
999 998 |
correct output |
---|
.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#... |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 29
Group: 3
Verdict: ACCEPTED
input |
---|
999 999 |
correct output |
---|
.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#... |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 30
Group: 3
Verdict: ACCEPTED
input |
---|
999 1000 |
correct output |
---|
.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#... |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 31
Group: 3
Verdict: ACCEPTED
input |
---|
1000 995 |
correct output |
---|
................................. |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 32
Group: 3
Verdict: ACCEPTED
input |
---|
1000 996 |
correct output |
---|
................................. |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 33
Group: 3
Verdict: ACCEPTED
input |
---|
1000 997 |
correct output |
---|
................................. |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 34
Group: 3
Verdict: ACCEPTED
input |
---|
1000 998 |
correct output |
---|
................................. |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 35
Group: 3
Verdict: ACCEPTED
input |
---|
1000 999 |
correct output |
---|
................................. |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |
Test 36
Group: 3
Verdict: ACCEPTED
input |
---|
1000 1000 |
correct output |
---|
................................. |
user output |
---|
.#...#.#...#.#...#.#...#.#...#... Truncated |