QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#430831 | #8729. Tikvani | thangthang | 0 | 0ms | 3736kb | C++20 | 2.2kb | 2024-06-04 15:39:23 | 2024-06-04 15:39:24 |
answer
// author : HuuHung
// 25.3.2024
#include <bits/stdc++.h>
#define ii pair <int, int>
#define F first
#define S second
#define ll long long
#define lb long double
#define pb push_back
#define vi vector <int>
#define vll vector <ll>
#define Bit(x, i) ((x) >> (i) & 1)
#define Mask(i) (1ll << (i))
#define All(v) (v).begin(), (v).end()
using namespace std;
void maxzi(auto &a, auto b){
a = max(a, b);
}
void minzi(auto &a, auto b){
a = min(a, b);
}
const int N = 405;
const int mod = 1e9 + 7;
const int LG = 20;
void add(auto &a, auto b){
a += b;
if (a >= mod) a -= mod;
if (a < 0) a += mod;
}
void mul(auto &a, auto b){
a = 1ll * a * b % mod;
}
int Pow(int a, int b){
if (b == 0) return 1;
if (b % 2) return 1ll * a * Pow(a, b - 1) % mod;
int c = Pow(a, b / 2);
return 1ll * c * c % mod;
}
// * end
int n, m, b[N], vis[N];
vector <int> adj[N];
bitset <N> val[N];
struct basis{
bitset <N> a[N];
int cnt = 0;
void ins(bitset <N> tmp){
for (int i = 1; i <= n; ++ i){
if (tmp[i]){
if (!a[i][i]) {
++ cnt;
a[i] = tmp;
return;
}
tmp ^= a[i];
}
}
}
} bas;
void dfs(int u){
vis[u] = 1;
for (int i : adj[u]){
int v = b[i];
if (!vis[v]){
val[v] = val[u];
val[v].flip(i);
dfs(v);
}
else {
bitset <N> tmp = val[u] ^ val[v];
tmp.flip(i);
bas.ins(tmp);
}
}
}
void solve(){
cin >> n >> m;
for (int i = 1, a; i <= m; ++ i){
cin >> a >> b[i];
adj[a].pb(i);
}
for (int i = 1; i <= n; ++ i){
val[i].reset();
for (int j = 1; j <= n; ++ j) vis[j] = 0;
dfs(i);
}
cout << Pow(2, m - bas.cnt);
}
int main(){
//freopen("code.inp", "r", stdin);
//freopen("code.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
while (t --) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 21
Accepted
time: 0ms
memory: 3668kb
input:
6 5 3 5 2 5 1 6 4 6 2 6
output:
32
result:
ok 1 number(s): "32"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
6 6 2 5 1 2 3 4 5 6 3 6 1 5
output:
32
result:
ok 1 number(s): "32"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
6 7 3 6 1 3 3 5 2 3 1 6 2 6 2 5
output:
16
result:
ok 1 number(s): "16"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
6 8 1 4 2 3 5 6 3 6 4 5 2 6 4 6 1 5
output:
32
result:
ok 1 number(s): "32"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
6 7 1 4 3 6 2 3 1 5 2 4 2 6 5 6
output:
64
result:
ok 1 number(s): "64"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
6 8 2 3 2 4 2 5 3 6 1 6 1 2 1 4 1 5
output:
32
result:
ok 1 number(s): "32"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
6 7 5 6 2 5 2 4 1 6 2 3 3 6 1 2
output:
32
result:
ok 1 number(s): "32"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
6 8 2 3 1 4 2 4 3 6 1 5 5 6 1 6 2 6
output:
64
result:
ok 1 number(s): "64"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
6 7 2 6 4 5 1 2 3 6 3 5 1 4 5 6
output:
32
result:
ok 1 number(s): "32"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
6 8 2 3 3 4 1 5 2 4 1 4 1 3 3 5 5 6
output:
32
result:
ok 1 number(s): "32"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
6 7 2 6 4 5 1 2 5 6 2 4 1 5 2 5
output:
16
result:
ok 1 number(s): "16"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
6 8 1 6 4 5 1 3 1 2 3 6 4 6 1 4 3 4
output:
32
result:
ok 1 number(s): "32"
Test #13:
score: -21
Wrong Answer
time: 0ms
memory: 3600kb
input:
6 15 1 5 2 5 3 4 4 5 2 4 2 6 1 4 1 3 4 6 5 6 1 2 1 6 3 5 2 3 3 6
output:
512
result:
wrong answer 1st numbers differ - expected: '32', found: '512'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #25:
score: 37
Accepted
time: 0ms
memory: 3600kb
input:
50 50 29 32 3 12 36 41 10 30 6 18 20 27 14 36 4 33 6 7 17 31 33 40 2 49 19 42 3 30 2 18 11 42 21 29 11 23 1 35 32 50 22 46 6 22 42 48 15 23 7 43 11 13 5 9 40 50 25 42 5 31 27 30 1 17 14 48 5 44 35 41 1 23 10 21 40 48 12 36 13 37 23 37 23 43 19 26 6 15 13 45 19 27 17 29 20 38 29 42 26 49
output:
974740338
result:
ok 1 number(s): "974740338"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
49 50 23 42 22 30 8 18 28 42 14 37 34 40 11 34 2 5 9 14 24 34 11 32 41 45 8 28 6 23 9 17 22 31 20 38 4 47 2 39 13 22 14 26 8 45 37 45 17 23 34 37 13 37 33 48 5 12 17 37 27 30 17 21 18 22 28 43 10 23 33 43 31 49 10 43 8 26 12 19 14 28 6 14 2 20 12 49 26 39 35 45 14 48 3 6 14 36 6 48 1 17
output:
743685088
result:
ok 1 number(s): "743685088"
Test #27:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
48 50 4 39 3 43 41 47 10 34 19 36 5 17 19 35 34 38 5 30 32 47 10 41 3 44 11 29 13 37 5 47 18 33 1 45 29 45 2 13 2 38 8 36 3 34 40 45 8 20 4 21 4 31 18 43 29 32 26 38 13 29 35 48 10 36 1 9 14 23 13 34 16 27 5 18 16 36 1 6 1 36 36 44 39 43 21 39 30 42 11 18 5 11 9 37 15 30 25 45 29 40
output:
371842544
result:
ok 1 number(s): "371842544"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
47 50 16 21 23 44 12 42 8 25 5 19 29 37 11 27 14 20 18 44 46 47 8 42 20 29 1 29 19 31 2 33 16 27 13 39 37 40 12 18 3 37 2 43 35 43 19 22 3 44 19 32 42 46 29 33 1 4 3 18 7 38 2 40 4 26 16 31 28 45 20 34 12 15 5 17 14 41 13 20 25 41 6 15 31 33 24 35 13 33 7 11 12 16 2 31 35 44 10 25 17 47
output:
487370169
result:
ok 1 number(s): "487370169"
Test #29:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
46 50 1 35 27 34 2 46 18 23 7 45 17 28 12 38 6 17 38 42 15 46 1 29 11 14 12 27 4 39 37 38 25 30 2 42 22 23 13 27 7 15 30 33 19 27 27 36 26 42 20 42 25 37 27 33 30 38 16 32 5 33 17 34 12 31 35 40 15 39 40 44 10 38 19 41 24 36 38 46 19 29 19 35 8 28 12 45 27 40 22 40 8 27 16 19 10 22 12 20 17 35
output:
487370169
result:
ok 1 number(s): "487370169"
Test #30:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
45 50 38 45 29 43 24 38 1 44 16 22 13 21 3 7 35 45 22 33 27 38 11 26 29 32 3 15 34 36 17 34 14 33 29 35 12 13 11 18 15 41 5 45 20 41 12 27 21 39 15 34 33 42 32 42 13 44 25 37 3 4 14 25 28 34 7 14 4 41 9 27 23 35 39 45 6 29 26 30 10 35 18 43 4 12 2 9 23 40 3 40 16 43 2 28 27 45 4 35 14 35
output:
371842544
result:
ok 1 number(s): "371842544"
Test #31:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
40 50 6 8 10 13 6 40 37 38 27 30 15 34 1 13 18 32 24 40 3 25 11 35 30 35 6 26 33 35 3 26 34 35 2 32 19 32 9 25 8 14 8 12 1 6 6 38 9 34 21 32 6 21 13 14 2 12 24 25 10 21 9 35 19 33 7 26 13 17 14 19 8 16 14 23 34 40 2 25 2 33 16 37 6 14 1 14 25 30 13 31 23 24 3 18 15 20 24 30 9 26
output:
877905026
result:
ok 1 number(s): "877905026"
Test #32:
score: -37
Wrong Answer
time: 0ms
memory: 3732kb
input:
30 50 4 11 18 25 17 22 4 28 8 15 11 26 2 25 2 4 12 21 20 26 6 30 4 21 15 18 25 28 13 16 27 28 18 22 21 25 13 27 23 26 24 30 6 26 3 24 1 4 7 30 1 5 6 12 10 19 1 6 11 29 14 18 1 14 1 25 12 20 9 28 12 16 10 28 18 28 3 26 11 13 15 25 4 13 7 18 28 30 7 28 19 25 14 28 3 15 8 19 6 13
output:
294967268
result:
wrong answer 1st numbers differ - expected: '73741817', found: '294967268'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%