Submission #300738

# Submission time Handle Problem Language Result Execution time Memory
300738 2020-09-17T12:54:18 Z BeanZ Making Friends on Joitter is Fun (JOI20_joitter2) C++14
0 / 100
1 ms 384 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){
        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

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 time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -