#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task2 "top1apio"
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1ll<<k)
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
//mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
//using i128 = __int128;
/*int rand(int l, int r)
{
return uniform_int_distribution<int>(l, r)(rd);
}*/
void phongbeo();
const int inf = 1e17+7;
const int mod2 = 1e9+7;
//const ll base=67;
ll n, m, s1, s2, s4, s3, sf, k, s5, s6, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2,
r2, center;
ll i, s10, s12, k1, k2, k3, s11, lim, w, l, r, dem5, dem6, dem7, dem9, root, en;
ll el = 19;
main()
{
///top1apio
if (fopen(task2".inp", "r"))
{
fin(task2);
fou(task2);
}
///top1apio
if (fopen(task".inp", "r"))
{
fin(task);
fou(task);
}
///top1apio
ios_base::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
// cin>>s1;
// ll t;cin>>t;while(t--)
phongbeo();
/// checktime
///top1apio
}
unordered_map<int,bool>cnt[50001];
int gg[11];
int ok[50001];
int dp[50001];
vector<int> d[50001],g[50001];
stack<int> p;
bool okk[50001];
bool huhu[50001];
void phongbeo()
{
cin>>n>>m;
for(int i=1; i<=n; i++)
{
cin>>s2;
dp[i]=s2;
if(s2<m)p.push(i),huhu[i]=1;
for(int j=1; j<=s2; j++)
cin>>s3,s3++,g[i].pb(s3),cnt[i][s3]=1;
}
while(!p.empty())
{
int i=p.top();
okk[i]=1;
p.pop();
for(auto x:g[i])
if(!okk[x])
{
d[i].pb(x);
}
for(int j=0; j<d[i].size(); j++)
{
s2=0;
for(int z=0; z<d[i].size(); z++)
{
if(cnt[d[i][j]][d[i][z]])s2+=mask(z);
}
gg[j]=s2;
}
int sz=d[i].size();
ok[0]=++dem;
for(int j=0; j<mask(sz); j++)
if(ok[j]==dem)
{
for(int z=0; z<d[i].size(); z++)
if(!bit(j,z)&&(gg[z]&j)==j)
{
ok[j+mask(z)]=dem;
}
s5=max(s5,1ll*sobit(j));
}
for(auto x:d[i])
if(!huhu[x])
{
dp[x]--;
if(dp[x]<m)huhu[x]=1,p.push(x);
}
}
cout<<s5+1;
}
컴파일 시 표준 에러 (stderr) 메시지
politicaldevelopment.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
32 | main()
| ^~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:11:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | #define fin(x) freopen(x".inp","r",stdin)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:37:9: note: in expansion of macro 'fin'
37 | fin(task2);
| ^~~
politicaldevelopment.cpp:12:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define fou(x) freopen(x".out","w",stdout)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:38:9: note: in expansion of macro 'fou'
38 | fou(task2);
| ^~~
politicaldevelopment.cpp:11:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | #define fin(x) freopen(x".inp","r",stdin)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:44:9: note: in expansion of macro 'fin'
44 | fin(task);
| ^~~
politicaldevelopment.cpp:12:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define fou(x) freopen(x".out","w",stdout)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:45:9: note: in expansion of macro 'fou'
45 | fou(task);
| ^~~
# | 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... |