CSES - Datatähti 2021 alku - Results
Submission details
Task:Arpakuutiot
Sender:jogr
Submission time:2020-10-11 16:10:12 +0300
Language:C++ (C++11)
Status:READY
Result:35
Feedback
groupverdictscore
#1ACCEPTED35
#20
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s1, 2details
#3ACCEPTED0.01 s1, 2details
#4ACCEPTED0.01 s1, 2details
#5ACCEPTED0.01 s1, 2details
#6ACCEPTED0.01 s1, 2details
#7ACCEPTED0.01 s1, 2details
#8ACCEPTED0.01 s1, 2details
#9ACCEPTED0.01 s1, 2details
#10ACCEPTED0.01 s1, 2details
#11ACCEPTED0.01 s2details
#120.01 s2details
#130.01 s2details
#14ACCEPTED0.01 s2details
#150.01 s2details
#160.01 s2details
#170.01 s2details
#180.01 s2details
#19ACCEPTED0.01 s2details
#200.01 s2details
#210.01 s2details
#220.01 s2details
#230.01 s2details
#240.01 s2details
#250.01 s2details
#260.01 s2details
#270.01 s2details
#280.01 s2details
#290.01 s2details
#300.01 s2details
#31ACCEPTED0.01 s1, 2details

Compiler report

input/code.cpp: In function 'std::vector<std::__cxx11::basic_string<char> > simplifytwo(std::vector<std::__cxx11::basic_string<char> >)':
input/code.cpp:255:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int s = 0; s < straights.size(); s++) {
                     ~~^~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'std::vector<std::__cxx11::basic_string<char> > simplify(std::vector<std::__cxx11::basic_string<char> >)':
input/code.cpp:357:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int s = 0; s < straights.size(); s++) {
                     ~~^~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'endpoint find_base(std::vector<std::__cxx11::basic_string<char> >)':
input/code.cpp:402:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = 0; i < ea.size(); i++) {
                             ~~^~~~~~~~~~~
input/code.cpp:416:31: w...

Code

#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<vector<string>> inp;

typedef int facetype;
#define BASE 0
#define FRONT 1
#define RIGHT 2
#define BACK 3
#define LEFT 4
#define OPPOSITE 5

/*
    3
   2x0
    1

A -1 represents a value outside the boundaries of the input
*/
#define EA_RIGHT    0
#define EA_BACK     1
#define EA_LEFT     2
#define EA_FRONT    3

struct elementarr {
    vector<int> elements;
};



class endpoint {
public:
    int x;
    int y;

    endpoint() {

    }
    endpoint(int x, int y) {
        this->x = x;
        this->y = y;
    }

    bool operator==(endpoint b) {
        return (this->x == b.x && this->y == b.y);
    }
};

class straight {
public:
    endpoint ep[2];
    bool is_vertical;

    straight() {

    }

    bool operator==(straight b) {
        return (this->ep[0] == b.ep[0] && this->ep[1] == b.ep[1]);
    }
};

class cube {
public:
    int base;
    int front;
    int right;
    int back;
    int left;
    int opposite;

    cube() {
        this->base = -1;
        this->front = -1;
        this->right = -1;
        this->back = -1;
        this->left = -1;
        this->opposite = -1;
    }

    cube rotate_with_base_and_front(int new_base, int new_front) {
        cube c = *this;
        cube temp = *this;

        if (new_front == temp.front) temp = c;
        else if (new_front == temp.left) {
            c.front     = temp.left;
            c.left      = temp.back;
            c.back      = temp.right;
            c.right     = temp.front;
        }
        else if (new_front == temp.back) {
            c.front     = temp.back;
            c.left      = temp.right;
            c.back      = temp.front;
            c.right     = temp.left;
        }
        else if (new_front == temp.right) {
            c.front     = temp.right;
            c.left      = temp.front;
            c.back      = temp.left;
            c.right     = temp.back;
        }
        else if (new_front == temp.opposite) { // upper face
            c.front     = temp.opposite;
            c.opposite  = temp.back;
            c.back      = temp.base;
            c.base      = temp.front;
        }
        else if (new_front == temp.base) { // bottom face
            c.front     = temp.base;
            c.base      = temp.back;
            c.back      = temp.opposite;
            c.opposite  = temp.front;
        }

        temp = c;
        if (new_base == temp.base) temp = c;
        //else if (new_base == temp.front) {
        //    c.base = temp.front;
        //    c.front = temp.opposite;
        //    c.opposite = temp.back;
        //    c.back = temp.base;
        //}
        //else if (new_base == temp.opposite) {
        //    c.base = temp.opposite;
        //    c.front = temp.back;
        //    c.opposite = temp.base;
        //    c.back = temp.front;
        //}
        //else if (new_base == temp.back) {
        //    c.base = temp.back;
        //    c.back = temp.opposite;
        //    c.opposite = temp.front;
        //    c.front = temp.base;
        //}
        else if (new_base == temp.opposite) {
            c.base      = temp.opposite;
            c.right     = temp.left;
            c.opposite  = temp.base;
            c.left      = temp.right;
        }
        else if (new_base == temp.right) {
            c.base      = temp.right;
            c.right     = temp.opposite;
            c.opposite  = temp.left;
            c.left      = temp.base;
        }
        else if (new_base == temp.left) {
            c.base      = temp.left;
            c.left      = temp.opposite;
            c.opposite  = temp.right;
            c.right     = temp.base;
        }

        return c;
    }

    bool operator==(cube b) {
        cube nb = b.rotate_with_base_and_front(this->base, this->front);

        bool iseqa = true;
        if (this->base      != nb.base       && this->base != nb.opposite) iseqa = false;
        if (this->front     != nb.front     ) iseqa = false;
        if (this->right     != nb.right     ) iseqa = false;
        if (this->back      != nb.back      ) iseqa = false;
        if (this->left      != nb.left      ) iseqa = false;
        if (this->opposite  != nb.opposite && this->opposite != nb.base) iseqa = false;

        //cube na = this->rotate_with_base_and_front(b.base, b.front);
        //
        //bool iseqb = true;
        //if (na.base      != b.base      ) iseqb = false;
        //if (na.front     != b.front     ) iseqb = false;
        //if (na.right     != b.right     ) iseqb = false;
        //if (na.back      != b.back      ) iseqb = false;
        //if (na.left      != b.left      ) iseqb = false;
        //if (na.opposite  != b.opposite  ) iseqb = false;

        return iseqa;// || iseqb;
    }
};


elementarr find_elements_around(vector<string> data, int x, int y) {
    elementarr ea;
    int offsetx[] = { 1, -1, 0, 0 };
    int offsety[] = { 0, 0, 1, -1 };
    for (int i = 0; i < 4; i++) {
        int ypos = y + (offsety[i]);
        int xpos = x + (offsetx[i]);
        if (xpos < 0 || xpos > 4 || ypos < 0 || ypos > 4) {
            ea.elements.push_back(-1);
            continue;
        }
        char ec = data[ypos].at(xpos);
        if (ec == '.') ea.elements.push_back(-1);
        else ea.elements.push_back(atoi(&ec));
    }
    return ea;
}
elementarr find_elements_around(vector<string> data, endpoint ep) { return find_elements_around(data, ep.x, ep.y); }


endpoint getpos(vector<string> data, int value) {
    for (int x = 0; x < 5; x++)
        for (int y = 0; y < 5; y++) {
            char c = data[y][x];
            if (atoi(&c) == value) {
                endpoint ep = endpoint(x, y);
                return ep;
            }
        }
    return endpoint(-1, -1);
}

int getvalue(vector<string> data, int x, int y) { // for create_cube()
    if (x < 0 || x > 4 || y < 0 || y > 4) return -1;
    else {
        char c = data[y][x];
        if (c == '.') return -1;
        return atoi(&c);
    }
}

vector<string> simplifytwo(vector<string> data) {
    vector<straight> straights;

    int offsetx[] = { 1, -1, 0, 0 };
    int offsety[] = { 0, 0, 1, -1 };
    for (int y = 0; y < 5; y++) {
        for (int x = 0; x < 5; x++) {
            char c = data[y].c_str()[x];
            if (c == '.') continue;
            straight s;
            for (int i = 0; i < 4; i++) {
                int ypos = y + (offsety[i]);
                int xpos = x + (offsetx[i]);
                if (xpos < 0 || xpos > 4 || ypos < 0 || ypos > 4) continue;
                char ec = data[ypos].c_str()[xpos];
                if (ec == '.') continue;
                //  creates endpoints in case its a straight of two or three
                s.ep[0].x = x;
                s.ep[0].y = y;
                s.ep[1].x = xpos;
                s.ep[1].y = ypos;
                straights.push_back(s);
            }
        }
    }
    for (int s = 0; s < straights.size(); s++) {
        vector<endpoint> eps;
        vector<endpoint> vps; // valuepoints, where the value is to be taken from
        int correctep = 0;
        for (int ei = 0; ei < 2; ei++) {
            int epi = (ei == 0) ? 1 : 0;

            int diffx = straights[s].ep[ei].x - straights[s].ep[epi].x;
            diffx = (diffx == 0) ? 0 : (int)((float)diffx / (float)abs(diffx));
            //cout << diffx << endl;
            int diffy = straights[s].ep[ei].y - straights[s].ep[epi].y;
            diffy = (diffy == 0) ? 0 : (int)((float)diffy / (float)abs(diffy));
            int xx, xy; // the coords around the straight: like this (ei == 0) x123. (ei == 1) .123x
            xx = straights[s].ep[ei].x + diffx;
            xy = straights[s].ep[ei].y + diffy;
            if (xy < 0 || xy > 4 || xx < 0 || xx > 4) continue;
            for (int i = 0; i < 2; i++) {
                int ypos = xy + (diffx * offsetx[i]); // swap the difference, so the numbers are looked from the opposite direction of the straight
                int xpos = xx + (diffy * offsetx[i]);
                if (xpos >= 0 && xpos <= 4 && ypos >= 0 && ypos <= 4) {
                    char ec = data[ypos].c_str()[xpos];
                    //cout << ec << endl << endl;
                    if (ec != '.') {
                        correctep++;
                        endpoint ep;
                        ep.x = xx; ep.y = xy;
                        eps.push_back(ep);

                        endpoint vp;
                        vp.x = xpos; vp.y = ypos;
                        vps.push_back(vp);
                        if (correctep == 2) break;
                    }
                }
            }
        }
        if (correctep == 2) {
            for (int i = 0; i < 2; i++) {
                int ypos = vps[i].y;
                int xpos = vps[i].x;
                int xy = eps[i].y;
                int xx = eps[i].x;
                char ec = data[ypos].c_str()[xpos];
                string repl(1, ec);
                data[xy].replace((size_t)xx, (size_t)1, repl);
                data[ypos].replace((size_t)xpos, (size_t)1, ".");
            }

        }
    }
    return data;
}

vector<string> simplify(vector<string> data) { // creates a straight of four, if doesn't already exist
    vector<straight> straights;

    int offsetx[] = { 1, -1, 0, 0 };
    int offsety[] = { 0, 0, 1, -1 };
    for (int y = 0; y < 5; y++) {
        bool complete = false;
        for (int x = 0; x < 5; x++) {
            char c = data[y].c_str()[x];
            if (c == '.') continue;
            straight s;
            bool isfour = false;
            for (int i = 0; i < 4; i++) {
                int ypos = y + (offsety[i]);
                int xpos = x + (offsetx[i]);
                if (xpos < 0 || xpos > 4 || ypos < 0 || ypos > 4) continue;
                char ec = data[ypos].c_str()[xpos];
                if (ec == '.') continue;
                ypos = y + (offsety[i] * 2);
                xpos = x + (offsetx[i] * 2);
                if (xpos < 0 || xpos > 4 || ypos < 0 || ypos > 4) continue;
                ec = data[ypos].c_str()[xpos];
                if (ec == '.') continue;
                //  creates endpoints in case its a straight of two or three
                s.ep[0].x = x;
                s.ep[0].y = y;
                s.ep[1].x = xpos;
                s.ep[1].y = ypos;
                complete = true;
                ypos = y + (offsety[i] * 3);
                xpos = x + (offsetx[i] * 3);
                if (xpos < 0 || xpos > 4 || ypos < 0 || ypos > 4) continue;
                ec = data[ypos].c_str()[xpos];
                if (ec == '.') continue;
                s.ep[0].x = x;
                s.ep[0].y = y;
                s.ep[1].x = xpos;
                s.ep[1].y = ypos;
                isfour = true;
            }
            if (isfour) return data; // if already has a straight of four
            if (complete) {
                straights.push_back(s);
            }
        }
    }
    if (straights.size() == 0) {
        return simplifytwo(data);
    }
    for (int s = 0; s < straights.size(); s++) {
        for (int ei = 0; ei < 2; ei++) {
            int epi = (ei == 0) ? 1 : 0;

            int diffx = straights[s].ep[ei].x - straights[s].ep[epi].x;
            diffx = (diffx == 0) ? 0 : (int)((float)diffx / (float)abs(diffx));
            //cout << diffx << endl;
            int diffy = straights[s].ep[ei].y - straights[s].ep[epi].y;
            diffy = (diffy == 0) ? 0 : (int)((float)diffy / (float)abs(diffy));
            int xx, xy;
            xx = straights[s].ep[ei].x + diffx;
            xy = straights[s].ep[ei].y + diffy;
            if (xy < 0 || xy > 4 || xx < 0 || xx > 4) continue;
            //data[xy].replace(xx, 1, "b");
            for (int i = 0; i < 2; i++) {
                int ypos = xy + (diffx * offsetx[i]); // swap the difference, so the numbers are looked from the opposite direction of the straight
                int xpos = xx + (diffy * offsetx[i]);
                if (xpos >= 0 && xpos <= 4 && ypos >= 0 && ypos <= 4) {
                    char ec = data[ypos].c_str()[xpos];
                    string repl(1, ec);
                    //cout << ec << endl << endl;
                    if (ec != '.') {
                        data[xy].replace((size_t)xx, (size_t)1, repl);
                        data[ypos].replace((size_t)xpos, (size_t)1, ".");
                        //for (string s : data) cout << s << endl;
                        //return data;
                    }
                }
            }
        }
    }
    return data;
}

endpoint find_base(vector<string> data) {
    int offsetx[] = { 1, -1, 0, 0 };
    int offsety[] = { 0, 0, 1, -1 };
    int max_num_around = 0;
    for (int y = 0; y < 5; y++) {
        
        for (int x = 0; x < 5; x++) {
            char c = data[y].at(x);
            if (c == '.') continue;
            int numbers_around = 0;
            vector<int> ea = find_elements_around(data, x, y).elements;
            for (int i = 0; i < ea.size(); i++) {
                if (ea[i] != -1) numbers_around++;
            }
            if (numbers_around > max_num_around) max_num_around = numbers_around;
        }
    }

    for (int y = 0; y < 5; y++) {
        for (int x = 0; x < 5; x++) {
            char c = data[y].at(x);
            int numbers_around = 0;
            if (c == '.') continue;

            vector<int> ea = find_elements_around(data, x, y).elements;
            for (int i = 0; i < ea.size(); i++) {
                if (ea[i] != -1) numbers_around++;
            }
            if (numbers_around >= max_num_around) {
                endpoint base = endpoint(x, y);
                return base;
            }
        }
    }
    endpoint ep(-1, -1);
    return ep;
}

// works only when a straight of is present
int get_opposite(vector<string> data, endpoint base) {
    int offsetx[] = { 2, -2, 0, 0 };
    int offsety[] = { 0, 0, 2, -2 };

    //cout << "x: " << base.x << " : y: " << base.y << endl;
    for (int i = 0; i < 4; i++) {
        int ypos = base.y + (offsety[i]);
        int xpos = base.x + (offsetx[i]);
        if (xpos < 0 || xpos > 4 || ypos < 0 || ypos > 4) continue;
        char ec = data[ypos].at(xpos);
        if (ec == '.') continue;
        return atoi(&ec);
    }

    int offx1[] = {  0, 1, 0, -1 };
    int offy1[] = { -1, 0, 1,  0 };
    int offm1[] = { 1, -1};

    int offx2[] = { 2,  2, -2, -2, 3, 3, -3, -3, 2, 2, -2, -2};
    int offy2[] = { 2, -2,  2, -2, 2,-2,  2, -2, 3,-3, 3, -3};


    int ox, oy;
    for (int i = 0; i < 4; i++) {
        ox = base.x + offx1[i];
        oy = base.y + offy1[i];
        if (oy < 0 || oy > 4 || ox < 0 || ox > 4) continue;
        if (data[oy][ox] != '.') {
            for (int j = 0; j < 2; j++) {
                ox = ox + (offy1[i] * offm1[j]);
                oy = oy + (offx1[i] * offm1[j]);
                if (oy < 0 || oy > 4 || ox < 0 || ox > 4) continue;
                if (data[oy][ox] != '.') {
                    ox = ox + offx1[i];
                    oy = oy + offy1[i];
                    if (oy < 0 || oy > 4 || ox < 0 || ox > 4) continue;
                    char ec = data[oy].at(ox);
                    //cout << "coaks: " << ec << " ok " << getvalue(data, base.x, base.y) << " coord " <<  ox << ":" << oy << endl;
                    if (ec != '.') {
                        return atoi(&ec);
                    }
                    ox -= offx1[i];
                    ox -= offy1[i];
                }
                ox -= (offy1[i] * offm1[j]);
                oy -= (offx1[i] * offm1[j]);
            }
        }

    }

    for (int i = 0; i < 12; i++) {
        // if not found in the default range, checking from 2 coords away
        ox = base.x + (offx2[i]);
        oy = base.y + (offy2[i]);
        if (oy < 0 || oy > 4 || ox < 0 || ox > 4) continue;
        if (data[oy][ox] != '.') {
            char ec = data[oy].at(ox);
            if (ec != '.')
                return atoi(&ec);
        }
    }

    //cout << "returning -1 " << endl << endl;
    return -1;
}


/*
cube set_cube_face(cube c, facetype ft, int value) {
    switch (ft) {
    case BASE: {
        c.base = value;
        break;
    };
    case FRONT: {
        c.front = value;
        break;
    };
    case RIGHT: {
        c.right = value;
        break;
    };
    case BACK: {
        c.back = value;
        break;
    };
    case LEFT: {
        c.left = value;
        break;
    };
    case OPPOSITE: {
        c.opposite = value;
        break;
    };
    };
    return c;
}

struct face {
    facetype ft;
    int value;
};
vector<face> get_faces_from_around(vector<string> data, facetype current_f, endpoint current_pos) {
    vector<face> faces;
    vector<int> ea = find_elements_around(data, current_pos).elements;


    facetype target_face;
    for (int i = 0; i < ea.size(); i++) {
        face f;
        if (ea[i] == -1) continue;
        switch (current_f) {
        case BASE: {
            if (i == EA_RIGHT)  f.ft = RIGHT;
            if (i == EA_BACK)   f.ft = BACK;
            if (i == EA_LEFT)   f.ft = LEFT;
            if (i == EA_FRONT)  f.ft = FRONT;
        };
        case FRONT: {
            if (i == EA_RIGHT)  f.ft = RIGHT;
            if (i == EA_BACK)   f.ft = BASE;
            if (i == EA_LEFT)   f.ft = LEFT;
            if (i == EA_FRONT)  f.ft = OPPOSITE;
        };
        case RIGHT: {
            if (i == EA_RIGHT)  f.ft = OPPOSITE;
            if (i == EA_BACK)   f.ft = BACK;
            if (i == EA_LEFT)   f.ft = BASE;
            if (i == EA_FRONT)  f.ft = FRONT;
        };
        case BACK: {

        };
        case LEFT: {

        };
        case OPPOSITE: {

        };
        }
    }
}
*/
/*
cube create_cube_any(vector<string> data) {
    int faces_left = 6;

    endpoint base = find_base(data); faces_left--;
    cube c;
    c.base = getvalue(data, base.x, base.y);
    c.front = -1;
    c.right = -1;
    c.back = -1;
    c.left = -1;
    c.opposite = -1;

    int p_opp = get_opposite(data, base);
    if (p_opp != -1) {
        c.opposite = p_opp;
        faces_left--;
    }

    while (faces_left > 0) {

    }

    vector<int> ea = find_elements_around(data, base).elements;
    for (int i = 0; i < ea.size(); i++) {
        if (ea[i] == -1) continue;
    }

}
*/
cube create_cube(vector<string> data) {
    endpoint base = find_base(data);
    cube c;
    c.base = -1;
    c.front = -1;
    c.right = -1;
    c.back = -1;
    c.left = -1;

    c.base = getvalue(data, base.x, base.y);
    c.front = getvalue(data, base.x, base.y - 1);;
    c.right = getvalue(data, base.x + 1, base.y);
    c.back = getvalue(data, base.x, base.y + 1);
    c.left = getvalue(data, base.x - 1, base.y);
    c.opposite = get_opposite(data, base);

    int check[6] = { c.base, c.front, c.right, c.back, c.left, c.opposite };
    int num_ndef = 0;
    for (int i = 0; i < 6; i++)
        if (check[i] == -1)
            ++num_ndef;

    while (num_ndef > 0) {
        for (int i = 0; i < 6; i++)
            if (check[i] == -1) {
                //int x = 21 - (c.base + c.front + c.right + c.back + c.left + c.opposite) - 1;
                if (i == 1) { c.front = get_opposite(data, getpos(data, c.back)); num_ndef--; check[i] = c.front;} //cout << " front" << endl; }
                if (i == 2) { c.right = get_opposite(data, getpos(data, c.left)); num_ndef--; check[i] = c.right;} //cout << " right" << endl; }
                if (i == 3) { c.back = get_opposite(data, getpos(data, c.front)); num_ndef--; check[i] = c.back;} //cout << " back" << endl; }
                if (i == 4) { c.left = get_opposite(data, getpos(data, c.right)); num_ndef--; check[i] = c.left;} //cout << " left" << endl; }
            }
    }
    
    //for (int i = 0; i < 6; i++) {
    //    cout << check[i] << ", ";
    //}
    //cout << endl;
    return c;
}

int main()
{
    int count;
    cin >> count;

    for (int i = 0; i < count; i++) {
        string temp;
        vector<string> vec;
        cin >> temp; vec.push_back(temp); temp.clear();
        cin >> temp; vec.push_back(temp); temp.clear();
        cin >> temp; vec.push_back(temp); temp.clear();
        cin >> temp; vec.push_back(temp); temp.clear();
        cin >> temp; vec.push_back(temp); temp.clear();
        inp.push_back(vec);
    }


    for (int i = 0; i < count; i++) {
        inp[i] = simplify(inp[i]);
    }

    //for (vector<string> v : inp) {
    //    for (string s : v)
    //        cout << s << endl;
    //    cout << endl << endl;
    //}


    vector<cube> cubes;
    for (int i = 0; i < count; i++) {
        cubes.push_back(create_cube(inp[i]));
    }

    //for (string v : inp[10]) cout << v << endl;


    //cout << cubes[7].base << endl;
    //cout << cubes[7].front << endl;
    //cout << cubes[7].right << endl;
    //cout << cubes[7].back << endl;
    //cout << cubes[7].left << endl;
    //cout << cubes[7].opposite << endl;
    //cout << endl;
    //cout << cubes[7].rotate_with_base_and_front(2, 6).base       << endl;
    //cout << cubes[7].rotate_with_base_and_front(2, 6).front      << endl;
    //cout << cubes[7].rotate_with_base_and_front(2, 6).right      << endl;
    //cout << cubes[7].rotate_with_base_and_front(2, 6).back       << endl;
    //cout << cubes[7].rotate_with_base_and_front(2, 6).left       << endl;
    //cout << cubes[7].rotate_with_base_and_front(2, 6).opposite   << endl;

    for (int i = 0; i < count; i++) {
        int counter = 0;
        for (int j = 0; j < count; j++) {
            if (i == j) continue;
            if (cubes[i] == cubes[j]) {
                if (counter > 0) cout << ' ';
                cout << (j + 1);
                counter++;
            }
        }
        if (counter == 0) cout << '-' << endl;
        else if ((i + 1 < count)) cout << endl;
    }

    /*for (vector<string> v: inp){
        for (string s: v) {
            cout << s << endl;
        }
        endpoint ep = find_base(v);
        cout << v[ep.y][ep.x] << " : " << get_opposite(v, ep);
        cout << endl;
    }*/
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
3
165..
.4...
.3...
.2...
...

correct output
3
-
1

user output
3
-
1

Test 2

Group: 1, 2

Verdict: ACCEPTED

input
5
264..
.5...
.3...
.1...
...

correct output
3
4 5
1
2 5
2 4

user output
3
4 5
1
2 5
2 4

Test 3

Group: 1, 2

Verdict: ACCEPTED

input
5
152..
.4...
.3...
.6...
...

correct output
3 5
4
1 5
2
1 3

user output
3 5
4
1 5
2
1 3

Test 4

Group: 1, 2

Verdict: ACCEPTED

input
5
142..
.6...
.3...
.5...
...

correct output
4 5
3
2
1 5
1 4

user output
4 5
3
2
1 5
1 4

Test 5

Group: 1, 2

Verdict: ACCEPTED

input
5
123..
.4...
.6...
.5...
...

correct output
3
4 5
1
2 5
2 4

user output
3
4 5
1
2 5
2 4

Test 6

Group: 1, 2

Verdict: ACCEPTED

input
5
213..
.6...
.4...
.5...
...

correct output
4 5
3
2
1 5
1 4

user output
4 5
3
2
1 5
1 4

Test 7

Group: 1, 2

Verdict: ACCEPTED

input
5
314..
.5...
.2...
.6...
...

correct output
3
4 5
1
2 5
2 4

user output
3
4 5
1
2 5
2 4

Test 8

Group: 1, 2

Verdict: ACCEPTED

input
5
163..
.2...
.5...
.4...
...

correct output
4 5
3
2
1 5
1 4

user output
4 5
3
2
1 5
1 4

Test 9

Group: 1, 2

Verdict: ACCEPTED

input
5
264..
.1...
.3...
.5...
...

correct output
2 3
1 3
1 2
5
4

user output
2 3
1 3
1 2
5
4

Test 10

Group: 1, 2

Verdict: ACCEPTED

input
5
214..
.3...
.5...
.6...
...

correct output
5
3 4
2 4
2 3
1

user output
5
3 4
2 4
2 3
1

Test 11

Group: 2

Verdict: ACCEPTED

input
10
.41..
.5...
.2...
36...
...

correct output
9
4 6 8
7 10
2 6 8
-
...

user output
9
4 6 8
7 10
2 6 8
-
...

Test 12

Group: 2

Verdict:

input
10
5....
1436.
.2...
.....
...

correct output
5 8
6 10
4 7 9
3 7 9
1 8
...

user output
-
6 10
-
7
-
...

Test 13

Group: 2

Verdict:

input
10
2....
41...
.63..
.5...
...

correct output
4 9 10
5 6 7 8
-
1 9 10
2 6 7 8
...

user output
4 10
6 7 8
-
1 10
-
...

Test 14

Group: 2

Verdict: ACCEPTED

input
10
1....
634..
..52.
.....
...

correct output
2 3 4 5 6 9 10
1 3 4 5 6 9 10
1 2 4 5 6 9 10
1 2 3 5 6 9 10
1 2 3 4 6 9 10
...

user output
2 3 4 5 6 9 10
1 3 4 5 6 9 10
1 2 4 5 6 9 10
1 2 3 5 6 9 10
1 2 3 4 6 9 10
...
Truncated

Test 15

Group: 2

Verdict:

input
10
.2...
4516.
3....
.....
...

correct output
5 7 9 10
8
4 6
3 6
1 7 9 10
...

user output
-
-
4 6
3 6
7 9 10
...

Test 16

Group: 2

Verdict:

input
10
.56..
.2...
.4...
31...
...

correct output
4 9
3 5 10
2 5 10
1 9
2 3 10
...

user output
4 9
3 5 10
2 5 10
1 9
2 3 10
...

Test 17

Group: 2

Verdict:

input
10
..62.
.31..
45...
.....
...

correct output
2 3 4 8
1 3 4 8
1 2 4 8
1 2 3 8
6 7 9 10
...

user output
-
-
4 8
3 8
6 7 9 10
...

Test 18

Group: 2

Verdict:

input
10
532..
.4...
.1...
.6...
...

correct output
3 8 9
5 6
1 8 9
7 10
2 6
...

user output
3 8 9
5 6
1 8 9
10
2 6
...

Test 19

Group: 2

Verdict: ACCEPTED

input
10
.64..
.1...
.3...
52...
...

correct output
2 5 6 7 8 9
1 5 6 7 8 9
4 10
3 10
1 2 6 7 8 9
...

user output
2 5 6 7 8 9
1 5 6 7 8 9
4 10
3 10
1 2 6 7 8 9
...
Truncated

Test 20

Group: 2

Verdict:

input
10
.4...
326..
.1...
.5...
...

correct output
4 7 8
6 9 10
5
1 7 8
3
...

user output
4 7
-
-
1 7
-
...

Test 21

Group: 2

Verdict:

input
20
.6...
.4...
31...
.25..
...

correct output
3 7 11 16
6
1 7 11 16
5 19
4 19
...

user output
7 11 16
6
-
-
19
...
Truncated

Test 22

Group: 2

Verdict:

input
20
3....
5614.
..2..
.....
...

correct output
7 10 11 17 20
12
4 9 13 15 18
3 9 13 15 18
8 14 16
...

user output
7 17 20
12
4 9 13 15 18
3 9 13 15 18
8 14 16
...
Truncated

Test 23

Group: 2

Verdict:

input
20
42...
.316.
.5...
.....
...

correct output
5 12 13 15 18
16 20
6 8 14
9 19
1 12 13 15 18
...

user output
5 12 13 15 18
20
6 14
-
1 12 13 15 18
...
Truncated

Test 24

Group: 2

Verdict:

input
20
..5..
.623.
41...
.....
...

correct output
2 6 11 12 13
1 6 11 12 13
5 16 18
7 14
3 16 18
...

user output
-
6 12 13
5 16
7 14
3 16
...
Truncated

Test 25

Group: 2

Verdict:

input
20
.46..
53...
.1...
.2...
...

correct output
2 3 5 7 15 17 19
1 3 5 7 15 17 19
1 2 5 7 15 17 19
8 10 11 14
1 2 3 7 15 17 19
...

user output
2 3 5 7 17 19
1 3 5 7 17 19
1 2 5 7 17 19
8 11 14
1 2 3 7 17 19
...
Truncated

Test 26

Group: 2

Verdict:

input
20
.61..
.4...
35...
.2...
...

correct output
8 10 20
3 17 18 19
2 17 18 19
14 15
6 7 9 13
...

user output
8 10 20
3 17 18 19
2 17 18 19
14
6 7 9 13
...
Truncated

Test 27

Group: 2

Verdict:

input
20
..2..
1463.
.5...
.....
...

correct output
2 3 5 6 9 20
1 3 5 6 9 20
1 2 5 6 9 20
11 19
1 2 3 6 9 20
...

user output
9
3 5 6 20
2 5 6 20
19
2 3 6 20
...
Truncated

Test 28

Group: 2

Verdict:

input
20
...4.
5132.
6....
.....
...

correct output
2 8 10 12 13 19
1 8 10 12 13 19
4 5 15 16 17
3 5 15 16 17
3 4 15 16 17
...

user output
2 8 10 12 13 19
1 8 10 12 13 19
-
5 15 17
4 15 17
...
Truncated

Test 29

Group: 2

Verdict:

input
20
.2...
.31..
45...
6....
...

correct output
5 8 9 14 17
3 10 16
2 10 16
13 15 19
1 8 9 14 17
...

user output
5 8 14 17
3 10 16
2 10 16
13 15 19
1 8 14 17
...
Truncated

Test 30

Group: 2

Verdict:

input
20
3....
452..
.1...
.6...
...

correct output
3 7 8 9 14 15 16 19
4 12 13 17
1 7 8 9 14 15 16 19
2 12 13 17
11 20
...

user output
7 8 9 14 15 16 19
4 12 13 17
-
2 12 13 17
11 20
...
Truncated

Test 31

Group: 1, 2

Verdict: ACCEPTED

input
2
546..
.3...
.2...
.1...
...

correct output
-
-

user output
-
-