CSES - HIIT Open 2018 - Results
Submission details
Task:Data Packet Routing
Sender:Karhukopla
Submission time:2018-05-26 12:49:23 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.21 sdetails
#3ACCEPTED0.21 sdetails
#4ACCEPTED0.21 sdetails
#5ACCEPTED0.04 sdetails
#6ACCEPTED0.03 sdetails
#7ACCEPTED0.02 sdetails
#8ACCEPTED0.03 sdetails
#9ACCEPTED0.02 sdetails

Code

#include <bits/stdc++.h>

#define ll long long
#define lll __int128
#define pii pair<int, int>
#define M 1000000007
#define N 101
#define push_back PB
#define F first
#define S second
using namespace std;

int v[1001][1001];

int solve() {
	int n, m;
	cin>>n>>m;
	int ans = 1;
	vector<pii> q(m);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin>>a>>b;
		if (v[a][b]) {
			ans = 2;
		}
		v[a][b] = 1;
		q[i] = {a, b};
	}
	for (pii p : q) {
		v[p.F][p.S] = 0;
	}
	return ans;
}

int main () {
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t; cin >> t;
	while(t--) cout<<solve()<<endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
2
10 3
1 2
2 1
3 4
...

correct output
1
2

user output
1
2

Test 2

Verdict: ACCEPTED

input
10
400 100000
292 392
33 131
61 254
...

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 3

Verdict: ACCEPTED

input
10
700 100000
603 318
570 280
374 589
...

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 4

Verdict: ACCEPTED

input
10
1000 100000
612 150
630 797
925 44
...

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 5

Verdict: ACCEPTED

input
10
1000 10000
25 713
450 653
659 325
...

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 6

Verdict: ACCEPTED

input
10
1000 3000
804 754
634 483
331 476
...

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 7

Verdict: ACCEPTED

input
10
1000 1000
529 538
501 784
783 645
...

correct output
2
2
2
2
2
...

user output
2
2
2
2
2
...

Test 8

Verdict: ACCEPTED

input
10
1000 300
602 710
622 952
254 471
...

correct output
1
2
2
1
1
...

user output
1
2
2
1
1
...

Test 9

Verdict: ACCEPTED

input
10
1000 100
295 836
509 67
436 838
...

correct output
1
1
1
1
1
...

user output
1
1
1
1
1
...