QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296702#4829. Mark on a Graphdefyers#0 3ms4820kbC++172.0kb2024-01-03 14:05:072024-01-03 14:05:08

Judging History

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

  • [2024-01-03 14:05:08]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:4820kb
  • [2024-01-03 14:05:07]
  • 提交

answer

#include "bits/stdc++.h"
#include <algorithm>
#include <random>

using namespace std;

using ll = long long;
using pii = pair<int, int>;


void encode() {

}

void decode() {

}

int mnmx = 1e9;
int mxmx = 0;
int mnmn = 1e9;
int mxmn = 0;

const int N = 1001;
vector<int> G[N];
set<pii> S;

bool has[N][N];
bool exist(int u, int v){
	return has[u][v] || has[v][u];
}

#define forn(i, j, k) for(int i = j; i < k; i++)
void test(int t) {

	for(auto [u, v] : S){
		G[u].push_back(v);
		G[v].push_back(u);
		has[u][v] = has[v][u] = 1;
	}

	bool success = false;
	for(int v = 1; v <= 1000; v++){
		int sz = G[v].size();
		forn(i, 0, sz) forn(j, i + 1, sz) forn(k, j + 1, sz) forn(l, k + 1, sz) {
			vector<int> adj {i, j, k, l};
			bool ok = true;
			for(int x = 0; x < 4; x++) {
				for (int y = x + 1; y < 4; y++){
					ok &= exist(adj[x], adj[y]);
				}
			}
			if(ok){
				cout << "ok" << endl;
				return;
			}
		}
	}

	int cnt = 0;
	for(int v = 1; v <= 1000; v++){
		int sz = G[v].size();
		forn(i, 0, sz) forn(j, i + 1, sz) forn(k, j + 1, sz) forn(l, k + 1, sz) {
			vector<int> adj {G[v][i], G[v][j], G[v][k], G[v][l]};
			for(int x = 0; x < 4; x++) {
				for (int y = x + 1; y < 4; y++){
					int u = adj[x], v = adj[y];
					cnt++;
					if(exist(u, v)){
						cout << "mark" << '\n';
						vector<pair<int, int>> ans;
						for(int a = 0; a < 4; a++){
							for(int b = a + 1; b < 4; b++){
								if(!exist(adj[a], adj[b])){
									ans.push_back({adj[a], adj[b]});
								}
							}
						}
						cout << ans.size() << '\n';
						for(auto [x, y] : ans){
							cout << x << ' ' << y << '\n';
						}
						return;
					}
				}
			}
		}
	}
	cout << cnt << endl;
	assert(false);
}
 
int32_t main() {
	cin.tie(0)->sync_with_stdio(0);
	cout << fixed << setprecision(10);

	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++){
		int u, v; cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
		has[u][v] = has[v][u] = true;
	}	
	test(1);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 4820kb

input:

1000 3560
603 151
415 20
102 569
895 552
678 734
24 614
689 518
440 223
751 919
223 433
711 551
502 634
706 583
812 501
514 535
780 751
720 530
532 384
888 139
864 791
292 675
171 881
30 592
464 557
280 299
654 650
894 335
250 532
792 10
83 969
118 771
579 300
852 983
243 940
957 939
817 889
911 319...

output:

mark
5
30 881
30 520
30 209
881 520
881 209

input:

1000 3565
626 777
295 222
665 811
534 33
682 101
107 833
155 950
656 183
184 217
383 221
676 187
815 771
335 355
759 167
640 763
707 250
342 897
224 873
974 302
521 228
368 12
794 262
113 210
639 831
511 688
95 125
440 102
70 757
464 840
11 36
355 37
232 687
178 201
182 394
201 34
617 583
221 937
25...

output:

mark
5
488 376
488 672
488 822
376 672
376 822

result:

wrong answer Token "mark" doesn't correspond to pattern "ok"