CSES - Aalto Competitive Programming 2024 - wk10 - Mon - Results
Submission details
Task:Modern art
Sender:hungdojan
Submission time:2024-11-11 16:54:40 +0200
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#28ACCEPTED0.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.00 sdetails
#33ACCEPTED0.00 sdetails
#34ACCEPTED0.00 sdetails
#35ACCEPTED0.00 sdetails
#36ACCEPTED0.00 sdetails
#37ACCEPTED0.00 sdetails
#38ACCEPTED0.00 sdetails
#39ACCEPTED0.00 sdetails
#40ACCEPTED0.00 sdetails
#41ACCEPTED0.00 sdetails
#42ACCEPTED0.01 sdetails
#43ACCEPTED0.00 sdetails
#44ACCEPTED0.00 sdetails
#45ACCEPTED0.00 sdetails
#46ACCEPTED0.00 sdetails
#47ACCEPTED0.00 sdetails
#48ACCEPTED0.00 sdetails
#49ACCEPTED0.01 sdetails
#50ACCEPTED0.01 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

#define I_2D(row, col, width) ((row) * (width) + (col))
#define PRINT_ARR(arr, n)                                                      \
  do {                                                                         \
    for (int i = 0; i < n; i++) {                                              \
      cout << arr[i] << " ";                                                   \
    }                                                                          \
    cout << "\n";                                                              \
  } while (0)
#define PRINT_VEC_ARR(v, n)                                                    \
  do {                                                                         \
    for (int i = 0; i < n; i++) {                                              \
      cout << i << ": ";                                                       \
      for (auto item : v[i]) {                                                 \
        cout << item << " ";                                                   \
      }                                                                        \
      cout << endl;                                                            \
    }                                                                          \
  } while (0)
#define endl '\n';

typedef long long ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, p;
  cin >> a >> p;
  ll opt_b = ceil(p / 4.0), opt_a = floor(p / 4.0);

  // cout << opt_a << " " << opt_b << endl;
  // ll min_area = (opt_a * opt_b) - ((opt_a - 1) * (opt_b - 1));
  // cout << min_area << endl;

  if (p & 1 || a < opt_a * opt_b - ((opt_a-1) * (opt_b-1)) || opt_a * opt_b < a) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  cout << "POSSIBLE" << endl;
  ll count = a - (opt_a + opt_b - 1);
  for (int i = 0; i < opt_a + 2; i++) {
    for (int j = 0; j < opt_b + 2; j++) {
      if (i == 0 || i == opt_a + 2 - 1) {
        cout << "0";
        continue;
      }
      if (j == 0 || j == opt_b + 2 - 1) {
        cout << "0";
        continue;
      }
      if (i == 1) {
        cout << "1";
        continue;
      }
      if (j == 1) {
        cout << "1";
        continue;
      }
      if (count) {
        cout << "1";
        count--;
      } else {
        cout << "0";
      }
    }
    cout << endl;
  }

  return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
5 14

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 2

Verdict: ACCEPTED

input
6 14

correct output
POSSIBLE
000
010
010
010
...

user output
POSSIBLE
000000
011110
010000
010000
...

Test 3

Verdict: ACCEPTED

input
7 10

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 4

Verdict: ACCEPTED

input
5 5

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 5

Verdict: ACCEPTED

input
6 22

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 6

Verdict: ACCEPTED

input
7 10

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 7

Verdict: ACCEPTED

input
5 20

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 8

Verdict: ACCEPTED

input
6 8

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 9

Verdict: ACCEPTED

input
7 4

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 10

Verdict: ACCEPTED

input
5 10

correct output
POSSIBLE
0000
0110
0110
0100
...

user output
POSSIBLE
00000
01110
01100
00000

Test 11

Verdict: ACCEPTED

input
10 25

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 12

Verdict: ACCEPTED

input
10 22

correct output
POSSIBLE
000
010
010
010
...

user output
POSSIBLE
00000000
01111110
01000000
01000000
...

Test 13

Verdict: ACCEPTED

input
10 14

correct output
POSSIBLE
0000
0110
0110
0110
...

user output
POSSIBLE
000000
011110
011110
011000
...

Test 14

Verdict: ACCEPTED

input
10 6

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 15

Verdict: ACCEPTED

input
10 37

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 16

Verdict: ACCEPTED

input
10 12

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 17

Verdict: ACCEPTED

input
10 39

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 18

Verdict: ACCEPTED

input
10 14

correct output
POSSIBLE
0000
0110
0110
0110
...

user output
POSSIBLE
000000
011110
011110
011000
...

Test 19

Verdict: ACCEPTED

input
10 4

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 20

Verdict: ACCEPTED

input
10 16

correct output
POSSIBLE
00000000
01111110
01111000
00000000

user output
POSSIBLE
000000
011110
011110
010000
...

Test 21

Verdict: ACCEPTED

input
100 239

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 22

Verdict: ACCEPTED

input
100 202

correct output
POSSIBLE
000
010
010
010
...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 23

Verdict: ACCEPTED

input
100 70

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
00000000000000000000
01111111111111111110
01111111111111111110
011111111111111111
...
Truncated

Test 24

Verdict: ACCEPTED

input
100 32

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 25

Verdict: ACCEPTED

input
100 361

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 26

Verdict: ACCEPTED

input
100 48

correct output
POSSIBLE
00000000000000000000
01111111111111111110
01111111111111111110
01111111111111111110
...

user output
POSSIBLE
00000000000000
01111111111110
01111111111110
01111111111110
...
Truncated

Test 27

Verdict: ACCEPTED

input
100 380

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 28

Verdict: ACCEPTED

input
100 76

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000
011111111111111111110
011111111111111111110
011111111111111
...
Truncated

Test 29

Verdict: ACCEPTED

input
100 8

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 30

Verdict: ACCEPTED

input
100 98

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000
011111111111111111111111110
0111111111111111111111111

...
Truncated

Test 31

Verdict: ACCEPTED

input
200 476

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 32

Verdict: ACCEPTED

input
200 402

correct output
POSSIBLE
000
010
010
010
...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 33

Verdict: ACCEPTED

input
200 120

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 34

Verdict: ACCEPTED

input
200 60

correct output
POSSIBLE
000000000000
011111111110
011111111110
011111111110
...

user output
POSSIBLE
00000000000000000
01111111111111110
01111111111111110
01111111111111110
...
Truncated

Test 35

Verdict: ACCEPTED

input
200 721

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 36

Verdict: ACCEPTED

input
200 74

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000
011111111111111111110
011111111111111111110
011111111111111
...
Truncated

Test 37

Verdict: ACCEPTED

input
200 759

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 38

Verdict: ACCEPTED

input
200 134

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 39

Verdict: ACCEPTED

input
200 12

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 40

Verdict: ACCEPTED

input
200 182

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 41

Verdict: ACCEPTED

input
1000 2373

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 42

Verdict: ACCEPTED

input
1000 1998

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 43

Verdict: ACCEPTED

input
1000 472

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 44

Verdict: ACCEPTED

input
1000 286

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 45

Verdict: ACCEPTED

input
1000 3603

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 46

Verdict: ACCEPTED

input
1000 228

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 47

Verdict: ACCEPTED

input
1000 3791

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 48

Verdict: ACCEPTED

input
1000 552

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated

Test 49

Verdict: ACCEPTED

input
1000 48

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 50

Verdict: ACCEPTED

input
1000 810

correct output
POSSIBLE
000000000000000000000000000000...

user output
POSSIBLE
000000000000000000000000000000...
Truncated