Submission #1334913

#TimeUsernameProblemLanguageResultExecution timeMemory
1334913vahagngPolitical Development (BOI17_politicaldevelopment)C++20
Compilation error
0 ms0 KiB
//----------vahagng----------//
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;

// template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define dbg(x)
#endif

void print(long long t) { cerr << t; }
void print(int t) { cerr << t; }
void print(string t) { cerr << t; }
void print(char t) { cerr << t; }
void print(double t) { cerr << t; }
void print(long double t) { cerr << t; }
void print(unsigned long long t) { cerr << t; }

template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T, class V> void print(T v[], V n) { cerr << "["; for (int i = 0; i < n; i++) { cerr << v[i] << " "; } cerr << "]"; }
template <class T, class V> void print(pair <T, V> p) { cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}"; }
template <class T> void print(vector <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(set <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(unordered_set <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T> void print(multiset <T> v) { cerr << "[ "; for (T i : v) { print(i); cerr << " "; } cerr << "]"; }
template <class T, class V> void print(map <T, V> v) { cerr << "[ "; for (auto i : v) { print(i); cerr << " "; } cerr << "]"; }

#define ll long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ld long double
#define sz(v) v.size()
#define endl '\n'

const ll inf = 2e18, mod = 1e9 + 7, mod2 = 998244353;

void SetIO(string str = "") {
    if (str != "") {
        freopen((str + ".in").c_str(), "r", stdin);
        freopen((str + ".out").c_str(), "w", stdout);
    }
    else {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
}

void FastIO() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int N = 5e5 + 10, M = 2e7 + 10;

mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());

ll binpow(ll a, ll b, ll m) {
    ll res = 1;
    while (b) {
        if (b & 1) {
            res = (res * a) % m;
        }
        b >>= 1;
        a = (a * a) % m;
    }
    return res;
}

__int128_t gcd(__int128_t a, __int128_t b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

__int128_t lcm(__int128_t a, __int128_t b) {
    return a / gcd(a, b) * b;
}

ll n, k;

int adj[50005][50005], deg[N], st[N];

bool check(int b) {
    for (int i = 1; i < b; i++) {
        for (int j = i + 1; j < b; j++) {
            if (!adj[st[i]][st[j]]) {
                return 0;
            }
        }
    }
    return 1;
}

bool findC(int i, int l, int s) {
    bool flag = 0;
    for (int j = i + 1; j <= n - (s - l); j++) {
        if (deg[j] >= s - 1) {
            st[l] = j;
            if (check(l + 1)) {
                if (l < s) {
                    flag |= findC(j, l + 1, s);
                }
                else {
                    return 1;
                }
            }
        }
    }
    return flag;
}

void solve(int tc) {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int d;
        cin >> d;
        while (d--) {
            int k;
            cin >> k;
            k++;
            adj[i][k] = 1;
            adj[k][i] = 1;
            deg[i]++;
        }
    }
    int l = 1, r = k, ans = -1;
    while (l <= r) {
        int m = (l + r) / 2;
        for (int i = 1; i <= n; i++) {
            st[i] = 0;
        }
        if (findC(0, 1, m)) {
            ans = m;
            l = m + 1;
        }
        else {
            r = m - 1;
        }
    }
    cout << ans << endl;
}


void precalc() {

}

int main() {
    // SetIO("teamwork");
    FastIO();
    int test_case = 1;
    // cin >> test_case;
    precalc();
    int cnt = 1;
    while (test_case--) {
        solve(cnt++);
    }
    return 0;
}

Compilation message (stderr)

politicaldevelopment.cpp: In function 'void SetIO(std::string)':
politicaldevelopment.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen((str + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen((str + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccbZCQTy.o: in function `print(long long)':
politicaldevelopment.cpp:(.text+0xa): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cerr' defined in .bss._ZSt4cerr section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccbZCQTy.o: in function `print(int)':
politicaldevelopment.cpp:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cerr' defined in .bss._ZSt4cerr section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccbZCQTy.o: in function `print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
politicaldevelopment.cpp:(.text+0x4e): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cerr' defined in .bss._ZSt4cerr section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccbZCQTy.o: in function `print(char)':
politicaldevelopment.cpp:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cerr' defined in .bss._ZSt4cerr section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
politicaldevelopment.cpp:(.text+0x82): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cerr' defined in .bss._ZSt4cerr section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccbZCQTy.o: in function `print(double)':
politicaldevelopment.cpp:(.text+0xe7): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cerr' defined in .bss._ZSt4cerr section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccbZCQTy.o: in function `print(long double)':
politicaldevelopment.cpp:(.text+0xf7): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cerr' defined in .bss._ZSt4cerr section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccbZCQTy.o: in function `print(unsigned long long)':
politicaldevelopment.cpp:(.text+0x10a): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cerr' defined in .bss._ZSt4cerr section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccbZCQTy.o: in function `FastIO()':
politicaldevelopment.cpp:(.text+0x132): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
politicaldevelopment.cpp:(.text+0x13d): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccbZCQTy.o: in function `findC(int, int, int)':
politicaldevelopment.cpp:(.text+0x361): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1f): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1ed): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x252): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2bc): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x316): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x50f): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x57d): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f0): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x654): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status