답안 #500820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500820 2022-01-01T10:28:30 Z pooty Island (NOI18_island) C++17
100 / 100
84 ms 7856 KB
#define REP(i, n) for(int i = 0; i < n; i ++)
#define REPL(i,m, n) for(int i = m; i < n; i ++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define SORT(arr) sort(arr.begin(), arr.end())
#define LSOne(S) ((S)&-(S))
#define M_PI 3.1415926535897932384
#define INF 999999999
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

void solve() {
	int n,m;cin>>n>>m;
	vi indeg(n+m,0);
	REP(i, n+m-1) {
		int u,v;cin>>u>>v;u--;v--;
		indeg[u]++;
		indeg[v]++;
	}
	
	//cout<<last<<"...\n";
	vi factarr(n+m+1,0);
	REP(i, n+m) {
		factarr[indeg[i]-1]++;
	}
	int tot = 0;
	vii ans;
	for (int i = n+m; i>1; i--) {
		tot += factarr[i];
		if (i > 1 && tot >= 1) {
			ans.push_back({tot, i});
		}
	}
	for (auto [ct, idx] : ans) {
		cout<<idx<<" "<<ct<<"\n";
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int tc = 1;
	REP(i, tc) {
		solve();
	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 58 ms 7016 KB Output is correct
4 Correct 79 ms 7716 KB Output is correct
5 Correct 18 ms 1824 KB Output is correct
6 Correct 84 ms 7856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 58 ms 7016 KB Output is correct
4 Correct 79 ms 7716 KB Output is correct
5 Correct 18 ms 1824 KB Output is correct
6 Correct 84 ms 7856 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 308 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 312 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 3 ms 588 KB Output is correct
27 Correct 64 ms 7572 KB Output is correct
28 Correct 69 ms 7856 KB Output is correct
29 Correct 21 ms 2756 KB Output is correct
30 Correct 33 ms 4500 KB Output is correct
31 Correct 6 ms 960 KB Output is correct
32 Correct 4 ms 716 KB Output is correct
33 Correct 30 ms 4084 KB Output is correct
34 Correct 32 ms 3792 KB Output is correct
35 Correct 42 ms 4404 KB Output is correct
36 Correct 41 ms 4420 KB Output is correct
37 Correct 0 ms 204 KB Output is correct