#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using ull = unsigned long long; constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);} ll nex(ll S) { return (S * 12345) % 1000003; } const int MN = 130; int N; vector g[MN]; int idx[MN]; namespace StopWatch { clock_t st; bool f = false; void start() { f = true; st = clock(); } int msecs() { assert(f); return (clock()-st)*1000 / CLOCKS_PER_SEC; } } void solve() { /* printf("N: %d\n", N); for (int i = 0; i < N; i++) { printf("vec %d:", i); for (int d: g[i]) { printf("%d ", d); } printf("\n"); }*/ int ans = 0; vector ans_p; srand(time(NULL)); iota(idx, idx+N, 0); StopWatch::start(); while (StopWatch::msecs() < 6000) { for (int fe = 0; fe < 1000; fe++) { random_shuffle(idx, idx+N); bool used[N]; fill_n(used, N, false); int co = 0; vector res; for (int i = 0; i < N; i++) { int p = idx[i]; if (!used[p]) { res.push_back(p+1); co++; for (int d: g[p]) { used[d] = true; } } } if (ans < co) { ans = co; ans_p = res; // printf("ans ref %d\n", co); } } } if (ans+1 == N) { printf("-1\n"); return; } printf("%d\n", ans+1); int m = (int)ans_p.size(); for (int i = 0; i < m; i++) { printf("%d", ans_p[i]); if (i < m-1) { printf(" "); } else { printf("\n"); } } } int main() { ll S; cin >> S; S = nex(S); N = (S % 120) + 2; S = nex(S); ll P = S; for (int i = 0; i < N; i++) { for (int j = i+1; j < N; j++) { S = nex(S); if (S >= P) { g[i].push_back(j); g[j].push_back(i); } } } solve(); return 0; }