# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
300730 | 2020-09-17T12:48:34 Z | BeanZ | 조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2) | C++14 | 5000 ms | 46972 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 (tmp[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 && tmp[j][u] == 0) ans++, tmp[j][u] = 1, mem.push_back({j, u}); if (dp[j][v] == 0 && tmp[j][v] == 0) ans++, tmp[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] && tmp[u][j] == 0){ ans++; tmp[u][j] = 1; mem.push_back({u, j}); } } tmp[u][v] = 1; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 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 | 3 ms | 896 KB | Output is correct |
8 | Correct | 4 ms | 896 KB | Output is correct |
9 | Correct | 3 ms | 896 KB | Output is correct |
10 | Correct | 1 ms | 768 KB | Output is correct |
11 | Correct | 2 ms | 768 KB | Output is correct |
12 | Correct | 2 ms | 768 KB | Output is correct |
13 | Correct | 1 ms | 768 KB | Output is correct |
14 | Correct | 2 ms | 768 KB | Output is correct |
15 | Correct | 1 ms | 768 KB | Output is correct |
16 | Correct | 1 ms | 776 KB | Output is correct |
17 | Correct | 1 ms | 768 KB | Output is correct |
18 | Correct | 2 ms | 768 KB | Output is correct |
19 | Correct | 2 ms | 768 KB | Output is correct |
20 | Correct | 2 ms | 768 KB | Output is correct |
21 | Correct | 3 ms | 896 KB | Output is correct |
22 | Correct | 2 ms | 768 KB | Output is correct |
23 | Correct | 2 ms | 896 KB | Output is correct |
24 | Correct | 2 ms | 768 KB | Output is correct |
25 | Correct | 3 ms | 896 KB | Output is correct |
26 | Correct | 2 ms | 768 KB | Output is correct |
27 | Correct | 2 ms | 896 KB | Output is correct |
28 | Correct | 2 ms | 768 KB | Output is correct |
29 | Correct | 2 ms | 768 KB | Output is correct |
30 | Correct | 1 ms | 768 KB | Output is correct |
31 | Correct | 2 ms | 896 KB | Output is correct |
32 | Correct | 2 ms | 768 KB | Output is correct |
33 | Correct | 3 ms | 896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 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 | 3 ms | 896 KB | Output is correct |
8 | Correct | 4 ms | 896 KB | Output is correct |
9 | Correct | 3 ms | 896 KB | Output is correct |
10 | Correct | 1 ms | 768 KB | Output is correct |
11 | Correct | 2 ms | 768 KB | Output is correct |
12 | Correct | 2 ms | 768 KB | Output is correct |
13 | Correct | 1 ms | 768 KB | Output is correct |
14 | Correct | 2 ms | 768 KB | Output is correct |
15 | Correct | 1 ms | 768 KB | Output is correct |
16 | Correct | 1 ms | 776 KB | Output is correct |
17 | Correct | 1 ms | 768 KB | Output is correct |
18 | Correct | 2 ms | 768 KB | Output is correct |
19 | Correct | 2 ms | 768 KB | Output is correct |
20 | Correct | 2 ms | 768 KB | Output is correct |
21 | Correct | 3 ms | 896 KB | Output is correct |
22 | Correct | 2 ms | 768 KB | Output is correct |
23 | Correct | 2 ms | 896 KB | Output is correct |
24 | Correct | 2 ms | 768 KB | Output is correct |
25 | Correct | 3 ms | 896 KB | Output is correct |
26 | Correct | 2 ms | 768 KB | Output is correct |
27 | Correct | 2 ms | 896 KB | Output is correct |
28 | Correct | 2 ms | 768 KB | Output is correct |
29 | Correct | 2 ms | 768 KB | Output is correct |
30 | Correct | 1 ms | 768 KB | Output is correct |
31 | Correct | 2 ms | 896 KB | Output is correct |
32 | Correct | 2 ms | 768 KB | Output is correct |
33 | Correct | 3 ms | 896 KB | Output is correct |
34 | Correct | 20 ms | 1536 KB | Output is correct |
35 | Execution timed out | 5072 ms | 46972 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 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 | 3 ms | 896 KB | Output is correct |
8 | Correct | 4 ms | 896 KB | Output is correct |
9 | Correct | 3 ms | 896 KB | Output is correct |
10 | Correct | 1 ms | 768 KB | Output is correct |
11 | Correct | 2 ms | 768 KB | Output is correct |
12 | Correct | 2 ms | 768 KB | Output is correct |
13 | Correct | 1 ms | 768 KB | Output is correct |
14 | Correct | 2 ms | 768 KB | Output is correct |
15 | Correct | 1 ms | 768 KB | Output is correct |
16 | Correct | 1 ms | 776 KB | Output is correct |
17 | Correct | 1 ms | 768 KB | Output is correct |
18 | Correct | 2 ms | 768 KB | Output is correct |
19 | Correct | 2 ms | 768 KB | Output is correct |
20 | Correct | 2 ms | 768 KB | Output is correct |
21 | Correct | 3 ms | 896 KB | Output is correct |
22 | Correct | 2 ms | 768 KB | Output is correct |
23 | Correct | 2 ms | 896 KB | Output is correct |
24 | Correct | 2 ms | 768 KB | Output is correct |
25 | Correct | 3 ms | 896 KB | Output is correct |
26 | Correct | 2 ms | 768 KB | Output is correct |
27 | Correct | 2 ms | 896 KB | Output is correct |
28 | Correct | 2 ms | 768 KB | Output is correct |
29 | Correct | 2 ms | 768 KB | Output is correct |
30 | Correct | 1 ms | 768 KB | Output is correct |
31 | Correct | 2 ms | 896 KB | Output is correct |
32 | Correct | 2 ms | 768 KB | Output is correct |
33 | Correct | 3 ms | 896 KB | Output is correct |
34 | Correct | 20 ms | 1536 KB | Output is correct |
35 | Execution timed out | 5072 ms | 46972 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |