제출 #169358

#제출 시각아이디문제언어결과실행 시간메모리
169358gabrielpessoaPolitical Development (BOI17_politicaldevelopment)C++14
16 / 100
3060 ms14980 KiB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;

const int ms = 4e5+5;

vector<int> g[ms];
int cur[ms];
int z = 0;

main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  int maxS = 0;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    maxS = max(maxS, d);
    g[i].resize(d);
    for(int j = 0; j < d; j++) {
      cin >> g[i][j];
    }
  }
  int ans = 1;
  if(maxS <= 10) {
    for(int i = 0; i < n; i++) {
      int t = g[i].size();
      for(int j = 0; j < (1 << t); j++) {
        vector<int> v = {i};
        for(int k = 0; k < t; k++) {
          if(j & (1 << k)) v.push_back(g[i][k]);
        }
        ++z;
        for(int k : v) {
          cur[k] = z;
        }
        bool possible = true;
        for(int k : v) {
          int cnt = 0;
          for(int l : g[k]) if(cur[l] == z) cnt++;
          if(cnt != v.size() -1) possible = false;
        }
        if(possible) ans = max(ans, (int) v.size());
      }
    }
  } else if(n <= 5000 && k <= 3) {
    for(int i = 0; i < n; i++) {
      if(g[i].size() > 0) ans = max(ans, 2);
      set<int> s;
      for(int j : g[i]) {
        for(int k : g[j]) {
          if(s.count(k)) ans = max(ans, 3);
        }
        s.insert(j);
      }
    }
  } 
  cout << ans << '\n';
}

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

politicaldevelopment.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:43:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           if(cnt != v.size() -1) possible = false;
              ~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...