Submission #294084

# Submission time Handle Problem Language Result Execution time Memory
294084 2020-09-08T15:07:38 Z 임성재(#5816) None (balkan16_acrobat) C++17
30 / 100
2000 ms 107512 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 em emplace 
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

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

int n, m;
int g[1111][1111];
int G[1111][1111];
int cnt = 0;

void rev(int x, int p, int c) {
	if(c == 1) {
		for(int i=1; i<=n; i++) {
			if(!g[x][i]) continue;
			g[i][x]++;
			g[x][i]--;

			rev(i, x, 3-c);
		}
	}
	else {
		for(int i=1; i<=n; i++) {
			if(!g[i][x]) continue;
			g[x][i]++;
			g[i][x]--;

			rev(i, x, 3-c);
		}
	}
}

int main() {
	fast;

	cin >> n >> m;

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

		if(a == b) {
			cout << -1;
			return 0;
		}
	}

	for(int i=1; i<=n; i++) {
		int cnt = 0, k = 0;
		for(int j=1; j<=n; j++) {
			if(g[i][j] & 1) cnt++;
		}

		if(cnt & 1) {
			rev(i, i, 1);
		}
	}

	vector<pii> ans;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			if(g[i][j] < G[i][j]) {
				ans.eb(i, j);
			}
		}
	}

	cout << ans.size() + n << "\n";
	for(auto i : ans) {
		cout << 1 << " " << i.fi << " " << i.se << "\n";
	}

	for(int i=1; i<=n; i++) {
		cout << 2 << " " << i << " " << (i == n ? 1 : i + 1) << "\n";
	}
}

Compilation message

main.cpp: In function 'int main()':
main.cpp:61:16: warning: unused variable 'k' [-Wunused-variable]
   61 |   int cnt = 0, k = 0;
      |                ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1024 KB Output is correct
7 Correct 2 ms 1152 KB Output is correct
8 Correct 1 ms 1024 KB Output is correct
9 Correct 1 ms 896 KB Output is correct
10 Correct 1 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1024 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1024 KB Output is correct
9 Correct 1 ms 896 KB Output is correct
10 Correct 1 ms 1152 KB Output is correct
11 Execution timed out 2079 ms 107512 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 512 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1024 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1024 KB Output is correct
9 Correct 1 ms 896 KB Output is correct
10 Correct 1 ms 1152 KB Output is correct
11 Execution timed out 2067 ms 106560 KB Time limit exceeded
12 Halted 0 ms 0 KB -