Submission #212720

#TimeUsernameProblemLanguageResultExecution timeMemory
212720BTheroMaking Friends on Joitter is Fun (JOI20_joitter2)C++17
1 / 100
5090 ms37372 KiB
#define DBG 1 // chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> //#include<ext/pb_ds/tree_policy.hpp> //#include<ext/pb_ds/assoc_container.hpp> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) if (DBG) cerr << #x << " = " << x << endl; using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> pii; //template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MAXN = (int)5e3 + 5; int adj[MAXN][MAXN]; int n, m, ans, sz; pii Q[MAXN * MAXN]; void push() { for (int i = 0; i < sz; ++i) { int x = Q[i].fi; int y = Q[i].se; for (int z = 1; z <= n; ++z) { if (z != x && z != y) { if (adj[z][x] && !adj[z][y]) { adj[z][y] = 1; ++ans; if (adj[y][z]) { Q[sz++] = mp(y, z); } } else if (adj[z][y] && !adj[z][x]) { adj[z][x] = 1; ++ans; if (adj[x][z]) { Q[sz++] = mp(x, z); } } } } } } void solve() { scanf("%d %d", &n, &m); for (int i = 1; i <= m; ++i) { int u, v; scanf("%d %d", &u, &v); if (adj[u][v] == 0) { adj[u][v] = 1; ++ans; sz = 0; if (adj[u][v] && adj[v][u]) { Q[sz++] = mp(u, v); } for (int w = 1; w <= n; ++w) { if (w != u && w != v && adj[v][w] && adj[w][v] && !adj[u][w]) { adj[u][w] = 1; ++ans; if (adj[w][u]) { Q[sz++] = mp(u, w); } } } push(); } printf("%d\n", ans); } } int main() { int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

joitter2.cpp: In function 'void solve()':
joitter2.cpp:58:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
joitter2.cpp:62:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...