답안 #1074916

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074916 2024-08-25T16:33:52 Z raduv Norela (info1cup18_norela) C++17
0 / 100
800 ms 348 KB
#include <bits/stdc++.h>
#define int long long
const int MAXM = 24;
const int MAXN = 60;
using namespace std;
long long v[MAXM];
int issmaller(int mask1, int mask2){
  int i;
  for( i = 0; i < MAXN; i++ ){
    if(((mask1 & (1 << i)) > 0) != ((mask2 & (1 << i)) > 0)){
      if(mask1 & (1 << i))
        return 1;
      return 0;
    }
  }
  return 0;
}
signed main()
{
    int n, m, q, bit, i, no, mn, mask, cmask;
    long long rez;
    scanf("%d%d", &n, &m);
    for( i = 0; i < m; i++ ){
      scanf("%d", &q);
      while(q--){
        scanf("%d", &bit);
        bit--;
        v[i] |= (1 << bit);
      }
    }
    mn = m + 1;
    cmask = 0;
    for( mask = 0; mask < (1 << m); mask++ ){
      rez = no = 0;
      for( i = 0; i < m; i++ ){
        if(mask & (1 << i)){
          rez ^= v[i];
          no++;
        }
      }
      if(rez == (1LL << n) - 1 && no < mn){
        mn = no;
        cmask = mask;
      }
      else if(rez == (1LL << n) - 1 && no == mn && issmaller(mask, cmask)){
        cmask = mask;
      }
    }
    printf("%d\n", mn);
    for( i = 0; i < m; i++ ){
      if(cmask & (1 << i))
        printf("%d ", i + 1);
    }
    return 0;
}

Compilation message

norela.cpp: In function 'int main()':
norela.cpp:22:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   22 |     scanf("%d%d", &n, &m);
      |            ~^     ~~
      |             |     |
      |             int*  long long int*
      |            %lld
norela.cpp:22:15: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   22 |     scanf("%d%d", &n, &m);
      |              ~^       ~~
      |               |       |
      |               int*    long long int*
      |              %lld
norela.cpp:24:15: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   24 |       scanf("%d", &q);
      |              ~^   ~~
      |               |   |
      |               |   long long int*
      |               int*
      |              %lld
norela.cpp:26:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   26 |         scanf("%d", &bit);
      |                ~^   ~~~~
      |                 |   |
      |                 |   long long int*
      |                 int*
      |                %lld
norela.cpp:49:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   49 |     printf("%d\n", mn);
      |             ~^     ~~
      |              |     |
      |              int   long long int
      |             %lld
norela.cpp:52:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   52 |         printf("%d ", i + 1);
      |                 ~^    ~~~~~
      |                  |      |
      |                  int    long long int
      |                 %lld
norela.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
norela.cpp:24:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |       scanf("%d", &q);
      |       ~~~~~^~~~~~~~~~
norela.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf("%d", &bit);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1056 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1056 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1056 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1056 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -