# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
803045 | YassineBenYounes | Political Development (BOI17_politicaldevelopment) | C++17 | 802 ms | 307720 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
typedef long long ll;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pbds tree<pair<ll, ll>, null_type, less<pair<ll,ll>>,rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
////////////////////Only Clear Code//////////////////////////
void usaco_problem(){
freopen("milkvisits.in", "r", stdin);
freopen("milkvisits.out", "w", stdout);
}
void init(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
const int mx = 5e4+5;
const int mxnd = mx*33;
const int LOG = 25;
const ll inf = 1e18;
const ll mod = 1e8;
vector<int> graph[mx];
int ans = 0;
vector<int> cur;
bool done[mx];
int n;
bitset<50005> bg[mx];
void solve(int k, bitset<50005> bs){
if(ans == 10)return;
ans = max(ans, k);
if(k == 9){
if(bs != 0) ans = 10;
return;
}
ans = max(ans, k);
if(k == 0){
for(int i = 0; i < n;i++){
cur.push_back(i);
done[i] = 1;
solve(k+1, bg[i]);
done[i] = 0;
cur.pop_back();
}
return;
}
bitset<50005> now = bs;
while(now != 0){
long unsigned int to = now._Find_first();
now[to] = 0;
solve(k+1, now & bg[to]);
if(ans == 10) return;
}
/*
for(int adj : graph[cur[0]]){
if(done[adj])continue;
bool take = 1;
for(int x : cur){
if(mp[x][adj] == 0)take = 0;
}
if(take){
cur.push_back(adj);
done[adj] = 1;
solve(k+1);
done[adj] = 0;
cur.pop_back();
}
}*/
}
void run_case(){
int k;cin >> n >> k;
for(int i = 0; i < n;i++){
int c;cin >> c;
while(c--){
int x;cin >> x;
//graph[i].push_back(x);
bg[i][x] = 1;
}
}
ans = 0;
solve(0,0);
cout << ans << endl;
}
int main(){
speed;
int t = 1;
//cin >> t;
while(t--){
run_case();
}
}
/*
NEVER GIVE UP!
DOING SMTHNG IS BETTER THAN DOING NTHNG!!!
Your Guide when stuck:
- Continue keyword only after reading the whole input
- Don't use memset with testcases
- Check for corner cases(n=1, n=0)
- Check where you declare n(Be careful of declaring it globally and in main)
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |