제출 #1346735

#제출 시각아이디문제언어결과실행 시간메모리
1346735phamngocphuc2008Light Bulbs (EGOI24_lightbulbs)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

using Grid = vector<vector<int>>;
int query(Grid grid)
{
    cout << '?' << endl;
    for(auto i : grid)
    {
        for(auto j : i) cout << j;
        cout << endl;
    }
    int x;
    cin >> x;
    return x;
}

void answer(Grid grid)
{
    cout << '!' << endl;
    for(auto i : grid)
    {
        for(auto j : i) cout << j;
        cout << endl;
    }
}

int main()
{
    int n;
    cin >> n;
    Grid ans(n, vector<int>(n));
    for(int i = 0; i < n; ++i)
    {
        int l = 1;
        int r = n+1;

        while(l < r)
        {

            Grid ask(n, vector<int>(n));
            int m = (l+r)/2;
            if(m == 1)
            {
                for(int j = 0; j < n; ++j) give_line[i][j] = 1;
                int num_straight = query(give_line);
                for(int j = 1; j < n; ++j) ask[i][j] = 1;
                int res = query(ask);
                if(res == (n-1)*n || res == num_straight)
                {
                    l = 1;
                    break;
                }
                else l=2;
            }
            else
            {
                for(int j = 0; j < m; ++j) ask[i][j] = 1;
                int res = query(ask);
                if(res == m*n) l=m+1;
                else r = m;
            }
        }
        --l;
        //cerr << l << '\n';
        if(l == n)
        {
            Grid line (n, vector<int>(n));
            for(int j = 0; j < n; ++j) line[i][j] = 1;
            answer(line);
            return 0;
        }
        ans[i][l] = 1;
    }
    answer(ans);
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:45:44: error: 'give_line' was not declared in this scope; did you mean 'getline'?
   45 |                 for(int j = 0; j < n; ++j) give_line[i][j] = 1;
      |                                            ^~~~~~~~~
      |                                            getline
Main.cpp:46:42: error: 'give_line' was not declared in this scope; did you mean 'getline'?
   46 |                 int num_straight = query(give_line);
      |                                          ^~~~~~~~~
      |                                          getline