QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#389107#6705. MedianMayuriWA 0ms3848kbC++144.2kb2024-04-14 02:28:332024-04-14 02:28:34

Judging History

你现在查看的是最新测评结果

  • [2024-04-14 02:28:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2024-04-14 02:28:33]
  • 提交

answer

//#define _CRT_SECURE_NO_WARNINGS
//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//typedef long double ld;
//#define endl '\n'
//const ll maxn = 2e5 + 5;
//ll T;
//ll n, m, k;
//ll u[maxn], v[maxn];
//
//int main()//D
//{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
//	cout.tie(0);
//	cin >> T;
//	while (T--) {
//		cin >> k;
//		string s; cin >> s;
//		cin >> n >> m;
//		for (ll i = 1; i <= m; i++) {
//			ll u, v; cin >> u >> v;
//		}
//		ll d = m - n + 2;
//		d--;
//		ll t = d % k;
//		if (s[t] == '1') cout << 2 << endl;
//		else cout << 1 << endl;
//	}
//}
//#define _CRT_SECURE_NO_WARNINGS
//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//typedef long double ld;
//#define endl '\n'
//const ll maxn = 2e5 + 5;
//ll T;
//ll n, m, k;
//ll u[maxn], v[maxn];
//ll dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
//ll f(char ch) {
//	if (ch == 'U')return 0;
//	if (ch == 'R')return 1;
//	if (ch == 'D')return 2;
//	if (ch == 'L')return 3;
//}
//int main()//C
//{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
//	cout.tie(0);
//	cin >> T;
//	while (T--) {
//		cin >> n >> k;
//		string s; cin >> s;
//		ll bx = 0, by = 0;
//		ll mx = 0, my = 0;
//		ll mmax = 0;
//		for (ll i = 0; i < s.size(); i++) {
//			ll t = f(s[i]);
//			bx += dx[t];
//			by += dy[t];
//			if (abs(bx) + abs(by) > abs(mx) + abs(my)) {
//				mx = bx;
//				my = by;
//			}
//		}
//		bx = bx * (k - 1);
//		by = by * (k - 1);
//		ll tx = 0, ty = 0;
//		for (ll i = 0; i < s.size(); i++) {
//			ll t = f(s[i]);
//			bx += dx[t];
//			by += dy[t];
//			if (abs(bx) + abs(by) > abs(tx) + abs(ty)) {
//				tx = bx;
//				ty = by;
//			}
//		}
//		cout << max(abs(tx) + abs(ty), abs(mx) + abs(my)) << endl;
//	}
//}
//#define _CRT_SECURE_NO_WARNINGS
//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//typedef long double ld;
//#define endl '\n'
//const ll maxn = 2e5 + 5;
//ll T;
//ll n, m;
//struct node {
//	ll l, r;
//	bool operator<(node t)const {
//		if (l == t.l) return r < t.r;
//		return l < t.l;
//	}
//}N[maxn];
//int main()//H
//{
//	ios::sync_with_stdio(0);
//	cin.tie(0);
//	cout.tie(0);
//	cin >> T;
//	while (T--) {
//		cin >> n;
//		for (ll i = 1; i <= n; i++) cin >> N[i].l >> N[i].r;
//		sort(N + 1, N + 1 + n);
//		ll cur = -1;
//		ll p = 1;
//		ll ans = 0;
//		priority_queue<ll, vector<ll>, greater<ll>>q;
//		while (p <= n) {
//			if (q.empty()) cur = N[p].l;
//			while (p <= n && cur == N[p].l) {
//				q.push(N[p].r);
//				p++;
//			}
//			while (q.size() && q.top() < cur)q.pop();
//			if (q.size() && cur <= q.top())ans++, q.pop();
//			cur++;
//		}
//		while (q.size()) {
//			if (q.top() >= cur) {
//				ans++;
//				cur++;
//			}
//			q.pop();
//		}
//		cout << ans << endl;
//	}
//}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define endl '\n'
const ll maxn = 100 + 5;
ll T;
ll n, m;
vector<ll>to[maxn];
vector<ll>to2[maxn];
ll sz[maxn];
ll sz2[maxn];
bool vis[maxn];
void dfs(ll u, ll s) {
	if (vis[u]) return;
	vis[u] = true;
	sz[s]++;
	sz2[u]++;
	for (auto v : to[u]) {
		dfs(v, s);
	}
}
ll in[maxn];
bool topu() {
	queue<ll>q;
	for (ll i = 1; i <= n; i++)if (!in[i])
		q.push(i);
	while (!q.empty()) {
		ll u = q.front();
		q.pop();
		for (auto v : to[u]){
			in[v]--;
			if (!in[v])
				q.push(v);
		}
	}
	for (ll i = 1; i <= n; i++)if (in[i])
		return false;
	return true;
}
int main()//H
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> T;
	while (T--) {
		for (ll i = 1; i <= n; i++)sz[i] = sz2[i] = in[i] =0,to[i].clear(), to2[i].clear();
		cin >> n >> m;
		bool flag = true;
		for (ll i = 1; i <= m; i++) {
			ll a, b; cin >> a >> b;
			if (a == b)flag = false;
			to[a].push_back(b);
			in[b]++;
		}
		vector<bool>ans(n + 1);
		if (topu()&&flag) {
			for (ll i = 1; i <= n; i++) {
				memset(vis, false, sizeof(vis));
				dfs(i, i);
			}
		}
		for (ll i = 1; i <= n; i++) {
			if (sz[i] - 1 <= n / 2 && sz2[i] - 1 <= n / 2)ans[i] = true;
			else ans[i] = false;
			cout << ans[i];
		}
		cout << endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3848kb

input:

2
5 4
1 2
3 2
2 4
2 5
3 2
1 1
2 3

output:

01000
111

result:

wrong answer 2nd lines differ - expected: '000', found: '111'