Submission #1058679

# Submission time Handle Problem Language Result Execution time Memory
1058679 2024-08-14T12:10:17 Z Zbyszek99 Make them Meet (EGOI24_makethemmeet) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace std;
//mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll rand(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;

int n;
int ans_[100][100];

int ask(vector<pii> v)
{
    string q = "?\n";
    set<pii> s;
    forall(it,v) s.insert(it);
    rep(i,n)
    {
        rep(j,n)
        {
            if(s.find({i,j}) == s.end())
            {
                q += '0';
            }
            else
            {
                q += '1';
            }
        }
        q += '\n';
    }
    cout << q << endl;
    cout.flush();
    int ans;
    cin >> ans;
    //cout.flush();
    return ans;
}

int check_seg(int i, int l, int r)
{
    vector<pii> v;
    rep2(j,l,r) v.pb({i,j});
    return ask(v);
}

void solve()
{
    cin >> n;
    cout.flush();
    rep(i,n)
    {
        if(check_seg(i,0,n-1) == n*n)
        {
            cout << "!\n";
            rep(i2,n)
            {
                rep(j,n)
                {
                    if(i2 == i) cout << "1";
                    else cout << "0\n";
                }
                cout << "\n";
            }
            cout.flush();
            return;
        }
    }
    vector<int> dont_know;
    pii ok = {-1,-1};
    rep(i,n)
    {
        int pocz = 0;
        int kon = n-1;
        int ans = -1;
        while(pocz <= kon)
        {
            int mid = (pocz+kon+1)/2;
            if(mid == 0)
            {
                ans = -1;
                dont_know.pb(i);
                break;
            }
            if(check_seg(i,0,mid) % n == 0)
            {
                pocz = mid+1;
            }
            else
            {
                kon = mid-1;
                ans = mid;
            }
        }
        if(ans != -1)
        {
            ok = {i,ans};
            ans_[i][ans] = 1;
        }
    }
    if(ok.ff == -1)
    {
        bool was_ = true;
        rep2(j,1,n-1)
        {
            if(ask({{0,0},{0,j}}) == n*2) was_ = false;
        }
        if(!was_)
        {
            ok = {0,1};
            ans_[0][1] = 1;
        }
        else
        {
            if(ask({{0,1},{0,2}}) == n)
            {
                ok = {0,1};
                ans_[0][1] = 1;
            }
            else
            {
                ok = {0,0};
                ans_[0][0] = 1;
            }
        }
    }
        forall(it,dont_know)
        {
            if(it == ok.ff) continue;
            if(ask({ok,{it,0}}) == n*2)
            {
                ans_[it][0] = 1;
            }
            else ans_[it][1] = 1;
        }
    cout <<"!\n";
    rep(i,n)
    {
        rep(j,n)
        {
            cout << ans_[i][j];
        }
        cout << "\n";
    }
    cout.flush();
}

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //random();
    int t = 1;
 //   cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Expected integer, but "?" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Expected integer, but "?" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Expected integer, but "?" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Expected integer, but "?" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Expected integer, but "?" found
2 Halted 0 ms 0 KB -