# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
300842 | 2020-09-17T14:14:58 Z | BeanZ | Making Friends on Joitter is Fun (JOI20_joitter2) | C++14 | 5000 ms | 31568 KB |
// I_LOVE_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 2e3 + 5; ll dp[N][N], tmp[N][N]; ll ans = 0; ll n; void construct(ll u, ll v){ vector<pair<ll, ll>> mem; if (dp[u][v] == 0) ans++; if (dp[v][u]){ for (int j = 1; j <= n; j++){ if (j == u || j == v) continue; ll cost = 0; cost = cost + dp[j][u]; cost = cost + dp[j][v]; if (cost == 1){ if (dp[j][u] == 0) ans++, dp[j][u] = 1, mem.push_back({j, u}); if (dp[j][v] == 0) ans++, dp[j][v] = 1, mem.push_back({j, v}); } } } for (int j = 1; j <= n; j++){ if (u == j || v == j) continue; if (dp[v][j] && dp[j][v] && dp[u][j] == 0){ ans++; dp[u][j] = 1; mem.push_back({u, j}); } } dp[u][v] = 1; for (auto j : mem){ construct(j.first, j.second); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll m; cin >> n >> m; for (int i = 1; i <= m; i++){ ll u, v; cin >> u >> v; construct(u, v); cout << ans << endl; } } /* */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 640 KB | Output is correct |
8 | Correct | 2 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 640 KB | Output is correct |
10 | Correct | 1 ms | 512 KB | Output is correct |
11 | Correct | 1 ms | 640 KB | Output is correct |
12 | Correct | 1 ms | 512 KB | Output is correct |
13 | Correct | 1 ms | 512 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Correct | 1 ms | 512 KB | Output is correct |
16 | Correct | 1 ms | 512 KB | Output is correct |
17 | Correct | 1 ms | 512 KB | Output is correct |
18 | Correct | 1 ms | 512 KB | Output is correct |
19 | Correct | 1 ms | 512 KB | Output is correct |
20 | Correct | 1 ms | 640 KB | Output is correct |
21 | Correct | 2 ms | 640 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 640 KB | Output is correct |
24 | Correct | 2 ms | 640 KB | Output is correct |
25 | Correct | 2 ms | 616 KB | Output is correct |
26 | Correct | 1 ms | 640 KB | Output is correct |
27 | Correct | 1 ms | 640 KB | Output is correct |
28 | Correct | 1 ms | 640 KB | Output is correct |
29 | Correct | 1 ms | 640 KB | Output is correct |
30 | Correct | 1 ms | 640 KB | Output is correct |
31 | Correct | 2 ms | 640 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 640 KB | Output is correct |
8 | Correct | 2 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 640 KB | Output is correct |
10 | Correct | 1 ms | 512 KB | Output is correct |
11 | Correct | 1 ms | 640 KB | Output is correct |
12 | Correct | 1 ms | 512 KB | Output is correct |
13 | Correct | 1 ms | 512 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Correct | 1 ms | 512 KB | Output is correct |
16 | Correct | 1 ms | 512 KB | Output is correct |
17 | Correct | 1 ms | 512 KB | Output is correct |
18 | Correct | 1 ms | 512 KB | Output is correct |
19 | Correct | 1 ms | 512 KB | Output is correct |
20 | Correct | 1 ms | 640 KB | Output is correct |
21 | Correct | 2 ms | 640 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 640 KB | Output is correct |
24 | Correct | 2 ms | 640 KB | Output is correct |
25 | Correct | 2 ms | 616 KB | Output is correct |
26 | Correct | 1 ms | 640 KB | Output is correct |
27 | Correct | 1 ms | 640 KB | Output is correct |
28 | Correct | 1 ms | 640 KB | Output is correct |
29 | Correct | 1 ms | 640 KB | Output is correct |
30 | Correct | 1 ms | 640 KB | Output is correct |
31 | Correct | 2 ms | 640 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 640 KB | Output is correct |
34 | Correct | 12 ms | 1024 KB | Output is correct |
35 | Execution timed out | 5064 ms | 31568 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 640 KB | Output is correct |
8 | Correct | 2 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 640 KB | Output is correct |
10 | Correct | 1 ms | 512 KB | Output is correct |
11 | Correct | 1 ms | 640 KB | Output is correct |
12 | Correct | 1 ms | 512 KB | Output is correct |
13 | Correct | 1 ms | 512 KB | Output is correct |
14 | Correct | 1 ms | 512 KB | Output is correct |
15 | Correct | 1 ms | 512 KB | Output is correct |
16 | Correct | 1 ms | 512 KB | Output is correct |
17 | Correct | 1 ms | 512 KB | Output is correct |
18 | Correct | 1 ms | 512 KB | Output is correct |
19 | Correct | 1 ms | 512 KB | Output is correct |
20 | Correct | 1 ms | 640 KB | Output is correct |
21 | Correct | 2 ms | 640 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 640 KB | Output is correct |
24 | Correct | 2 ms | 640 KB | Output is correct |
25 | Correct | 2 ms | 616 KB | Output is correct |
26 | Correct | 1 ms | 640 KB | Output is correct |
27 | Correct | 1 ms | 640 KB | Output is correct |
28 | Correct | 1 ms | 640 KB | Output is correct |
29 | Correct | 1 ms | 640 KB | Output is correct |
30 | Correct | 1 ms | 640 KB | Output is correct |
31 | Correct | 2 ms | 640 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 640 KB | Output is correct |
34 | Correct | 12 ms | 1024 KB | Output is correct |
35 | Execution timed out | 5064 ms | 31568 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |