CSES - Aalto Competitive Programming 2024 - wk10 - Mon - Results
Submission details
Task:Modern art
Sender:Niilo
Submission time:2024-11-11 17:49:56 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#20.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#50.00 sdetails
#6ACCEPTED0.00 sdetails
#70.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#100.00 sdetails
#11ACCEPTED0.00 sdetails
#120.00 sdetails
#130.00 sdetails
#14ACCEPTED0.00 sdetails
#150.00 sdetails
#16ACCEPTED0.00 sdetails
#170.00 sdetails
#180.00 sdetails
#19ACCEPTED0.00 sdetails
#200.00 sdetails
#210.00 sdetails
#22ACCEPTED0.00 sdetails
#230.00 sdetails
#24ACCEPTED0.00 sdetails
#250.00 sdetails
#260.00 sdetails
#270.00 sdetails
#280.00 sdetails
#29ACCEPTED0.00 sdetails
#300.00 sdetails
#310.00 sdetails
#320.00 sdetails
#330.00 sdetails
#340.00 sdetails
#350.00 sdetails
#360.00 sdetails
#370.00 sdetails
#380.00 sdetails
#39ACCEPTED0.00 sdetails
#400.00 sdetails
#410.00 sdetails
#420.00 sdetails
#430.00 sdetails
#440.00 sdetails
#450.00 sdetails
#460.00 sdetails
#470.00 sdetails
#480.00 sdetails
#49ACCEPTED0.00 sdetails
#500.00 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i=a;i<(b);++i)
#define all(x) begin(x),end(x)
#define sz(x) int((x).size())
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using ld = long double;

int a, p, sl;
int cx = 1, cy = 1;
bool Z[1002][1001];
bool balance = false;

int main() {
  cin >> a >> p;
  sl = int(sqrt(a));
  rep(i,0,sl) {
    Z[0][i] = 1;
    Z[i][0] = 1;
  }
  if (sl*sl < a) {
    Z[0][sl] = 1;
    if ((sl+1)*sl < a) {
      a -= 1;
      p -= 2;
      Z[sl][0] = 1;
    }
    a -= 1;
    p -= 2;
    a -= sl*2-1;
    p -= 4+(sl*4-2)*2;
    ++sl;
  } else {
    a -= sl*2-1;
    p -= 4 + (sl*2-2)*2;
  }
  assert(a >= 0);
  while (a > 0) {
    if (p < a*2) {
      cout << "IMPOSSIBLE\n";
      return 0;
    }
    if (p > a*2) {
      Z[cy][cx] = 1;
      ++cx;
      if (cx == sl) {
        cx = 1;
        ++cy;
      }
    }
    if (p == a*2) {
      cx = sl;
      while (a > 0) {
        Z[0][cx++] = 1;
        ++sl;
        --a;
        p -= 2;
      }
    }
    a -= 1;
  }
  /*if (p > 0) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }*/
  cout << "POSSIBLE\n";
  rep(i,0,sl) cout << "0";
  cout << "00\n";
  rep(i,0,sl+1) {
    cout << "0";
    rep(j,0,sl) {
      cout << Z[i][j];
    }
    cout << "0\n";
  }
}

Test details

Test 1

Verdict: ACCEPTED

input
5 14

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 2

Verdict:

input
6 14

correct output
POSSIBLE
000
010
010
010
...

user output
IMPOSSIBLE

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:

input
6 22

correct output
IMPOSSIBLE

user output
POSSIBLE
0000000
0111110
0100000
0000000
...

Test 6

Verdict: ACCEPTED

input
7 10

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 7

Verdict:

input
5 20

correct output
IMPOSSIBLE

user output
POSSIBLE
000000
011110
010000
000000
...

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:

input
5 10

correct output
POSSIBLE
0000
0110
0110
0100
...

user output
IMPOSSIBLE

Test 11

Verdict: ACCEPTED

input
10 25

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 12

Verdict:

input
10 22

correct output
POSSIBLE
000
010
010
010
...

user output
IMPOSSIBLE

Test 13

Verdict:

input
10 14

correct output
POSSIBLE
0000
0110
0110
0110
...

user output
IMPOSSIBLE

Test 14

Verdict: ACCEPTED

input
10 6

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 15

Verdict:

input
10 37

correct output
IMPOSSIBLE

user output
POSSIBLE
000000
011110
011110
011000
...

Test 16

Verdict: ACCEPTED

input
10 12

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 17

Verdict:

input
10 39

correct output
IMPOSSIBLE

user output
POSSIBLE
000000
011110
011110
011000
...

Test 18

Verdict:

input
10 14

correct output
POSSIBLE
0000
0110
0110
0110
...

user output
IMPOSSIBLE

Test 19

Verdict: ACCEPTED

input
10 4

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 20

Verdict:

input
10 16

correct output
POSSIBLE
00000000
01111110
01111000
00000000

user output
IMPOSSIBLE

Test 21

Verdict:

input
100 239

correct output
IMPOSSIBLE

user output
POSSIBLE
000000000000
011111111110
011111111110
011111111110
...

Test 22

Verdict: ACCEPTED

input
100 202

correct output
POSSIBLE
000
010
010
010
...

user output
POSSIBLE
000000000000000000000000000000...

Test 23

Verdict:

input
100 70

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 24

Verdict: ACCEPTED

input
100 32

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 25

Verdict:

input
100 361

correct output
IMPOSSIBLE

user output
POSSIBLE
000000000000
011111111110
011111111110
011111111110
...

Test 26

Verdict:

input
100 48

correct output
POSSIBLE
00000000000000000000
01111111111111111110
01111111111111111110
01111111111111111110
...

user output
IMPOSSIBLE

Test 27

Verdict:

input
100 380

correct output
IMPOSSIBLE

user output
POSSIBLE
000000000000
011111111110
011111111110
011111111110
...

Test 28

Verdict:

input
100 76

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 29

Verdict: ACCEPTED

input
100 8

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 30

Verdict:

input
100 98

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 31

Verdict:

input
200 476

correct output
IMPOSSIBLE

user output
POSSIBLE
00000000000000000
01111111111111110
01111111111111110
01111111111111110
...

Test 32

Verdict:

input
200 402

correct output
POSSIBLE
000
010
010
010
...

user output
IMPOSSIBLE

Test 33

Verdict:

input
200 120

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 34

Verdict:

input
200 60

correct output
POSSIBLE
000000000000
011111111110
011111111110
011111111110
...

user output
IMPOSSIBLE

Test 35

Verdict:

input
200 721

correct output
IMPOSSIBLE

user output
POSSIBLE
00000000000000000
01111111111111110
01111111111111110
01111111111111110
...

Test 36

Verdict:

input
200 74

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 37

Verdict:

input
200 759

correct output
IMPOSSIBLE

user output
POSSIBLE
00000000000000000
01111111111111110
01111111111111110
01111111111111110
...

Test 38

Verdict:

input
200 134

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 39

Verdict: ACCEPTED

input
200 12

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 40

Verdict:

input
200 182

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 41

Verdict:

input
1000 2373

correct output
IMPOSSIBLE

user output
POSSIBLE
000000000000000000000000000000...

Test 42

Verdict:

input
1000 1998

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 43

Verdict:

input
1000 472

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 44

Verdict:

input
1000 286

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 45

Verdict:

input
1000 3603

correct output
IMPOSSIBLE

user output
POSSIBLE
000000000000000000000000000000...

Test 46

Verdict:

input
1000 228

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 47

Verdict:

input
1000 3791

correct output
IMPOSSIBLE

user output
POSSIBLE
000000000000000000000000000000...

Test 48

Verdict:

input
1000 552

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE

Test 49

Verdict: ACCEPTED

input
1000 48

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 50

Verdict:

input
1000 810

correct output
POSSIBLE
000000000000000000000000000000...

user output
IMPOSSIBLE