Submission #1053720

# Submission time Handle Problem Language Result Execution time Memory
1053720 2024-08-11T16:15:16 Z SamAnd Light Bulbs (EGOI24_lightbulbs) C++17
60.6667 / 100
213 ms 1032 KB
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 102;

int n;
char b[N][N];
char a[N][N];

bool c[N][N];
map<vector<pair<int, int> >, int> mp;
int qry(vector<pair<int, int> >& v)
{
    sort(all(v));
    if (mp.find(v) != mp.end())
        return mp[v];
    cout << '?' << endl;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (binary_search(all(v), m_p(i, j)))
                cout << '1';
            else
                cout << '0';
        }
        cout << endl;
    }
    int ans = 0;

    /*memset(c, false, sizeof c);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (binary_search(all(v), m_p(i, j)))
            {
                if (b[i][j] == 'H')
                {
                    for (int j = 1; j <= n; ++j)
                        c[i][j] = true;
                }
                else
                {
                    for (int i = 1; i <= n; ++i)
                        c[i][j] = true;
                }
            }
        }
    }
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            ans += c[i][j];*/

    cin >> ans;
    return mp[v] = ans;
}

void solv()
{
    cin >> n;
    //for (int i = 1; i <= n; ++i)
    //    cin >> (b[i] + 1);

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            a[i][j] = '0';

    for (int i = 1; i <= n; ++i)
    {
        int l = 2, r = n;
        int u = n + 1;
        while (l <= r)
        {
            int m = (l + r) / 2;
            vector<pair<int, int> > v;
            for (int j = 1; j <= m; ++j)
                v.push_back(m_p(i, j));
            if (qry(v) != m * n)
            {
                u = m;
                r = m - 1;
            }
            else
                l = m + 1;
        }
        if (u == n + 1)
        {
            cout << '!' << endl;
            for (int ii = 1; ii <= n; ++ii)
            {
                if (ii != i)
                {
                    for (int j = 1; j <= n; ++j)
                        cout << '0';
                }
                else
                {
                    for (int j = 1; j <= n; ++j)
                        cout << '1';
                }
                cout << endl;
            }
            return;
        }
        else
        {
            if (u >= 3)
            {
                a[i][u] = '1';
            }
            else
            {
                vector<pair<int, int> > v;
                for (int j = 1; j <= 2; ++j)
                    v.push_back(m_p(i, j));
                if (qry(v) == n)
                {
                    a[i][1] = '1';
                }
                else
                {
                    vector<pair<int, int> > v;
                    for (int j = 1; j <= 3; ++j)
                        v.push_back(m_p(i, j));
                    if (qry(v) == 2 * n - 1)
                    {
                        a[i][3] = '1';
                    }
                    else
                    {
                        vector<pair<int, int> > v;
                        v.push_back(m_p(i, 1));
                        v.push_back(m_p(i, 3));
                        if (qry(v) == n * 2)
                            a[i][2] = '1';
                        else
                            a[i][1] = '1';
                    }
                }
            }
        }
    }

    cout << '!' << endl;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            cout << a[i][j];
        }
        cout << endl;
    }
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    ios_base::sync_with_stdio(false), cin.tie(0);

    int tt = 1;
    //cin >> tt;
    while (tt--)
    {
        solv();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 0 ms 344 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 0 ms 344 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 0 ms 344 KB Output is correct
54 Correct 0 ms 344 KB Output is correct
55 Correct 0 ms 344 KB Output is correct
56 Correct 1 ms 344 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 0 ms 344 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 1 ms 344 KB Output is correct
56 Correct 1 ms 344 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Partially correct 130 ms 508 KB Partially correct
60 Correct 2 ms 344 KB Output is correct
61 Partially correct 150 ms 504 KB Partially correct
62 Partially correct 181 ms 600 KB Partially correct
63 Partially correct 147 ms 800 KB Partially correct
64 Partially correct 162 ms 848 KB Partially correct
65 Partially correct 159 ms 588 KB Partially correct
66 Partially correct 159 ms 1032 KB Partially correct
67 Partially correct 143 ms 596 KB Partially correct
68 Partially correct 180 ms 592 KB Partially correct
69 Partially correct 138 ms 592 KB Partially correct
70 Partially correct 142 ms 592 KB Partially correct
71 Partially correct 163 ms 504 KB Partially correct
72 Correct 2 ms 596 KB Output is correct
73 Partially correct 46 ms 344 KB Partially correct
74 Partially correct 99 ms 344 KB Partially correct
75 Partially correct 213 ms 488 KB Partially correct
76 Partially correct 132 ms 992 KB Partially correct
77 Partially correct 161 ms 848 KB Partially correct
78 Partially correct 33 ms 496 KB Partially correct
79 Partially correct 140 ms 548 KB Partially correct
80 Partially correct 132 ms 516 KB Partially correct
81 Partially correct 148 ms 848 KB Partially correct
82 Partially correct 156 ms 600 KB Partially correct
83 Partially correct 126 ms 492 KB Partially correct
84 Partially correct 130 ms 496 KB Partially correct
85 Partially correct 198 ms 628 KB Partially correct
86 Partially correct 120 ms 588 KB Partially correct
87 Partially correct 153 ms 592 KB Partially correct
88 Partially correct 165 ms 492 KB Partially correct
89 Partially correct 146 ms 588 KB Partially correct
90 Partially correct 125 ms 600 KB Partially correct
91 Partially correct 119 ms 344 KB Partially correct
92 Partially correct 143 ms 796 KB Partially correct
93 Partially correct 145 ms 588 KB Partially correct
94 Partially correct 139 ms 592 KB Partially correct
95 Partially correct 143 ms 752 KB Partially correct
96 Partially correct 144 ms 560 KB Partially correct
97 Correct 0 ms 344 KB Output is correct