# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
695338 | Nhoksocqt1 | Geppetto (COCI15_geppetto) | C++17 | 13 ms | 328 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
template<class X, class Y>
inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
return uniform_int_distribution<int>(l, r)(rng);
}
int readInt() {
bool minus = false;
int result = 0;
char ch;
ch = getchar();
while(true) {
if(ch == '-') break;
if(ch >= '0' && ch <= '9') break;
ch = getchar();
}
if(ch == '-') minus = true; else result = ch - '0';
while(true) {
ch = getchar();
if (ch < '0' || ch > '9') break;
result = result * 10 + (ch - '0');
}
if(minus)
return -result;
else
return result;
}
const int MAXN = 20;
int maskNot[MAXN], numIngredient, numPair;
void process() {
cin >> numIngredient >> numPair;
for (int i = 0; i < numPair; ++i) {
int u, v;
cin >> u >> v;
maskNot[u - 1] |= (1 << (v - 1));
maskNot[v - 1] |= (1 << (u - 1));
}
int res(0);
for (int mask = 0; mask < (1 << numIngredient); ++mask) {
++res;
for (int i1 = mask; i1 > 0; i1 ^= i1 & -i1) {
int i = __builtin_ctz(i1 & -i1);
if((maskNot[i] & mask) > 0) {
--res;
break;
}
}
}
cout << res;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("geppetto.inp", "r", stdin);
// freopen("geppetto.out", "w", stdout);
process();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |