답안 #1048544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048544 2024-08-08T08:14:46 Z 5시간 대회를 2시간으로 즐길 수 있다니 완전 럭키비키잖아~(#11095) Light Bulbs (EGOI24_lightbulbs) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int n;
int pos[100];
int arr[100][100];

int query() {
    printf("?\n");
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            printf("%d",arr[i][j]);
        }
        printf("\n");
    }
    fflush(stdout);
    int x;
    scanf("%d",&x);
    return x;
}

void answer() {
    printf("!\n");
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            printf("%d",arr[i][j]);
        }
        printf("\n");
    }
    fflush(stdout);
}

int solve(int x) {
    memset(arr,0,sizeof(arr));
    for(int i=0;i<n;i++) {
        arr[x][i]=true;
    }
    if (query()==n*n) {
        answer();
        return -1;
    }
    int lo=-1;
    int hi=n-1;
    while (lo+1<hi) {
        int mid=(lo+hi)/2;
        memset(arr,0,sizeof(arr));
        for(int i=0;i<=mid;i++) {
            arr[x][i]=true;
        }
        if (query()==(mid+1)*n) {
            lo=mid;
        }
        else {
            hi=mid;
        }
    }
    return hi;
}

int main(void) {
    scanf("%d",&n);
    bool flag=true;
    for(int i=0;i<n;i++) {
        int got=solve(i);
        if (got==-1) {
            return 0;
        }
        pos[i]=got;
    }
    memst(arr,0,sizeof(arr));
    for(int i=0;i<n;i++) {
        arr[i][pos[i]]=1;
    }
    answer();
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:70:5: error: 'memst' was not declared in this scope; did you mean 'memset'?
   70 |     memst(arr,0,sizeof(arr));
      |     ^~~~~
      |     memset
Main.cpp:62:10: warning: unused variable 'flag' [-Wunused-variable]
   62 |     bool flag=true;
      |          ^~~~
Main.cpp: In function 'int query()':
Main.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d",&x);
      |     ~~~~~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:61:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~