답안 #500817

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500817 2022-01-01T10:26:29 Z pooty Island (NOI18_island) C++17
0 / 100
1 ms 460 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;
	set<int> processed;
	vvi adj(n+m);
	vi indeg(n+m,0);
	REP(i, n+m-1) {
		int u,v;cin>>u>>v;u--;v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
		indeg[u]++;
		indeg[v]++;
	}
	
	//cout<<last<<"...\n";
	vi factarr(n+m+1,0);
	REP(i, n+m+1) {
		factarr[indeg[i]-1]++;
	}
	int tot = 0;
	vii ans;
	for (int i = n+m-1; 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 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 436 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -