This page is still under construction.

Parts of this page are still being built. What you see may change.

Find the Hyper Spot to Lie Down In

Time limit4sMemory limit1024 MB

Summary
Given an 11-dimensional N-cube with K obstacle cells, count the runs of at least two empty cells along each of the 11 axes.
Level

Medium6 of 10

Topics
Hash map, Sorting, Implementation
Solved
No attempts yet

Problem

Shift spent a year traveling the world in VR inside the metaverse. Tired from the trip, Shift booked a room for one night at a nearby Virtual Condo.

The rooms in the Virtual Condo form an 1111-dimensional hypercube of N×N×N×N×N×N×N×N×N×N×NN \times N \times N \times N \times N \times N \times N \times N \times N \times N \times N cells. Each cell is a unit cube of size 1×1×1×1×1×1×1×1×1×1×11 \times 1 \times 1 \times 1 \times 1 \times 1 \times 1 \times 1 \times 1 \times 1 \times 1, parallel to the xx, yy, zz, uu, vv, ww, rr, ss, tt, oo, and pp axes. Each cell is identified by coordinates (x,y,z,u,v,w,r,s,t,o,p)\left(x,y,z,u,v,w,r,s,t,o,p\right) with 1≤x,y,z,u,v,w,r,s,t,o,p≤N1 \le x,y,z,u,v,w,r,s,t,o,p \le N.

The room is full of cargo that cannot be moved. Each cargo item is a single unit cell, and the cargo takes up space Shift could use to lie down. Shift has to find a place to lie down in this poor environment.

A place to lie down needs 2 or more empty cells in a row in a straight line. Shift can stretch out along that line. Shift can lie down in any of eleven directions, each parallel to one of the eleven axes. Shift always stretches fully, so the body always touches a wall or a cargo item. Shift never lies down halfway.

In the room shown in the picture above, there are 9 765 6279\,765\,627 places to lie down along the xx axis, 9 765 6259\,765\,625 along the yy axis, 9 765 6259\,765\,625 along the zz axis, 9 765 6259\,765\,625 along the uu axis, 9 765 6259\,765\,625 along the vv axis, 9 765 6259\,765\,625 along the ww axis, 9 765 6249\,765\,624 along the rr axis, 9 765 6259\,765\,625 along the ss axis, 9 765 6259\,765\,625 along the tt axis, 9 765 6259\,765\,625 along the oo axis, and 9 765 6279\,765\,627 along the pp axis.

Given the room size NN and the layout of the room, write a program that counts the places to lie down along each of the eleven axes.

Input

The first line contains the room size NN and the number of obstacles KK (0≤K≤111 1110 \le K \le 111\,111).

The next KK lines give the coordinates of the obstacles in the order xx, yy, zz, uu, vv, ww, rr, ss, tt, oo, pp. No two or more obstacles occupy the same position.

Output

On the first line, print the number of places to lie down along the xx axis.

On the second line, print the number of places to lie down along the yy axis.

On the third line, print the number of places to lie down along the zz axis.

On the fourth line, print the number of places to lie down along the uu axis.

On the fifth line, print the number of places to lie down along the vv axis.

On the sixth line, print the number of places to lie down along the ww axis.

On the seventh line, print the number of places to lie down along the rr axis.

On the eighth line, print the number of places to lie down along the ss axis.

On the ninth line, print the number of places to lie down along the tt axis.

On the tenth line, print the number of places to lie down along the oo axis.

On the eleventh line, print the number of places to lie down along the pp axis.

Examples3

  1. Example 1

    Input
    2 2
    1 1 1 1 1 1 1 1 1 1 1
    2 1 1 1 1 1 1 1 1 1 1
    
    Expected output
    1023
    1022
    1022
    1022
    1022
    1022
    1022
    1022
    1022
    1022
    1022
    
  2. Example 2

    Input
    5 4
    5 1 2 4 1 2 1 1 2 1 2
    3 2 1 2 4 2 2 2 1 5 3
    5 1 5 4 1 2 1 1 2 1 2
    3 2 1 2 4 2 4 2 1 5 3
    
    Expected output
    9765627
    9765625
    9765625
    9765625
    9765625
    9765625
    9765624
    9765625
    9765625
    9765625
    9765627
    
  3. Example 3

    Input
    32 7
    21 5 15 12 29 9 18 17 20 16 3
    23 11 26 19 25 7 24 14 31 8 5
    21 5 15 12 31 9 18 17 20 16 3
    10 1 6 3 22 28 2 13 4 27 1
    10 2 6 3 22 28 2 13 4 27 1
    23 11 23 19 25 7 24 14 31 8 5
    32 30 21 5 15 12 3 10 1 6 12
    
    Expected output
    1125899906842630
    1125899906842629
    1125899906842631
    1125899906842631
    1125899906842629
    1125899906842631
    1125899906842629
    1125899906842631
    1125899906842628
    1125899906842631
    1125899906842629