Submission #1053705

# Submission time Handle Problem Language Result Execution time Memory
1053705 2024-08-11T16:00:48 Z SamAnd Light Bulbs (EGOI24_lightbulbs) C++17
0 / 100
1 ms 344 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 a[N][N];

int qry(vector<pair<int, int> >& v)
{
    sort(all(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;
    cin >> ans;
    return ans;
}

void solv()
{
    cin >> n;

    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 <= 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 1 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 Incorrect 0 ms 344 KB The lamps do not light up the entire grid
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 Incorrect 0 ms 344 KB The lamps do not light up the entire grid
5 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 344 KB The lamps do not light up the entire grid
5 Halted 0 ms 0 KB -