Submission #1152242

#TimeUsernameProblemLanguageResultExecution timeMemory
1152242Muhammad_AneeqLight Bulbs (EGOI24_lightbulbs)C++20
22 / 100
582 ms500 KiB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/

#include <iostream>
#include <vector>
#include <set>
#include <map>
#warning check the output
using namespace std;
int n;
int const N=110;
int gr[N][N];
int ask(vector<pair<int,int>>x)
{
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            gr[i][j]=0;
    for (auto [i,j]:x)
        gr[i][j]=1;
    cout<<"?\n";
    for (int j=0;j<n;j++)
    {
        for (int k=0;k<n;k++)
        {
            cout<<gr[j][k];
        }
        cout<<'\n';
    }
    int z;
    cin>>z;
    return z;
}
void ans(vector<pair<int,int>>x)
{
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            gr[i][j]=0;
    for (auto [i,j]:x)
        gr[i][j]=1;
    cout<<"!\n";
    for (int j=0;j<n;j++)
    {
        for (int k=0;k<n;k++)
        {
            cout<<gr[j][k];
        }
        cout<<'\n';
    }
}
void checkv(vector<pair<int,int>>d)
{   
    set<int>s;
    vector<pair<int,int>>x;
    for (auto [i,j]:d)
    {
        if (s.find(j)==s.end())
        {
            x.push_back({i,j});
            s.insert(j);
        }
    }
    int z=ask(x);
    if (z==n*n)
    {
        ans(x);
        exit(0);
    }
}
void checkh(vector<pair<int,int>>d)
{   
    set<int>s;
    vector<pair<int,int>>x;
    for (auto [i,j]:d)
    {
        if (s.find(i)==s.end())
        {
            x.push_back({i,j});
            s.insert(i);
        }
    }
    int z=ask(x);
    if (z==n*n)
    {
        ans(x);
        exit(0);
    }
}
inline void solve()
{
    cin>>n;
    vector<pair<int,int>>h,v;
    v={{0,0}};
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            if (i==0&&j==0)
                continue;
            int z=ask({{0,0},{i,j}});
            if (z==(2*n-1))
                h.push_back({i,j});
            else
                v.push_back({i,j});
        }
    }
    checkh(h);
    checkh(v);
    checkv(v);
    checkv(h);
}
int main()
{
    int t=1;
    for (int i=1;i<=t;i++)
    {
        solve();
    }
}

Compilation message (stderr)

Main.cpp:11:2: warning: #warning check the output [-Wcpp]
   11 | #warning check the output
      |  ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...