Submission #269072

# Submission time Handle Problem Language Result Execution time Memory
269072 2020-08-17T05:02:21 Z 임성재(#5102) Making Friends on Joitter is Fun (JOI20_joitter2) C++17
0 / 100
0 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
const ll Mod = 1e9 + 7;

int n, m;
int g[60][60];
int ans;

void update(int a, int b) {
	//cout << a << "!!! " << b << "\n";

	if(g[b][a]) {
		for(int i=1; i<=n; i++) {
			if(i == a || i == b) continue;
			if(g[i][b] && !g[i][a]) {
				ans++;
				g[i][a] = 1;
				update(i, a);
			}
		}
	}

	for(int i=1; i<=n; i++) {
		if(i == a || i == b) continue;
		
		if(g[b][i] && g[i][b] && !g[a][i]) {
			ans++;
			g[a][i] = 1;
			update(a, i);
		}
	}
}

int main() {
	fast;

	cin >> n >> m;

	for(int i=1; i<=m; i++) {
		int a, b;
		cin >> a >> b;

		if(!g[a][b]) {
			ans++;
			g[a][b] = 1;

			update(a, b);
		}

		cout << ans << "\n";;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -