wangmingwei
2024-11-15 10:30:22
注意到有个
那剩下的
vector<int>ok[20];
inline void prework()
{
for(int n{1};n<=19;n++)
{
for(int s{1};s<(1<<n);s++)
{
bitset<21>nowi(s);
nowi<<=1;
bitset<21>light;
for(int i{1};i<=n;i++)
{
if(nowi[i])
{
for(int j{i};j<=n;j+=i) light[j] = !light[j];
}
}
if((int)light.count() > n/5) continue;
ok[n].push_back(s);
}
}
}
inline void work()
{
int n = read();
if(n >= 20)
{
writeln(n);
for(int i{1};i<=n;i++) writek(i);
int m = read();
while(m--) read(),read();
return;
}
int m = read();
vector<int>a(m+1),b(m+1);
for(int i{1};i<=m;i++) a[i] = read(),b[i] = read();
for(int s : ok[n])
{
bitset<25>nowi(s);
nowi<<=1;
bool tg = true;
for(int i{1};i<=m;i++)
if(nowi[a[i]] && !nowi[b[i]]) { tg = false;break;}
if(!tg) continue;
writeln(nowi.count());
for(int i{1};i<=n;i++)
if(nowi[i]) writek(i);
putchar(10);return;
}
puts("-1");
}