Submission #300738

#TimeUsernameProblemLanguageResultExecution timeMemory
300738BeanZMaking Friends on Joitter is Fun (JOI20_joitter2)C++14
0 / 100
1 ms384 KiB
// 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){ 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, construct(j, u); if (dp[j][v] == 0 && tmp[j][v] == 0) ans++, tmp[j][v] = 1, construct(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; construct(u, j); } } tmp[u][v] = 1; dp[u][v] = 1; } 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 (stderr)

joitter2.cpp: In function 'int main()':
joitter2.cpp:41:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   41 |                 freopen("test.inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joitter2.cpp:42:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   42 |                 freopen("test.out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...