Code Submission Evaluation System Login

CSES - HIIT Open 2018

HIIT Open 2018

Contest start:2018-05-26 11:00:00
Contest end:2018-05-26 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2018-05-26 11:41:23
Task:Data Packet Routing
Sender:Ukkonen Fan Club
Submission time:2018-05-26 11:41:23
Status:READY
Result:ACCEPTED

Show test data

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:25:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < adds.size(); ++i) {
                   ~~^~~~~~~~~~~~~

Code

#include <iostream>
#include <vector>

const int N = 1000;
bool used[N][N];

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	int t;
	std::cin >> t;
	for (int cs = 0; cs < t; ++cs) {
		int n, m;
		std::cin >> n >> m;
		int ans = 1;
		std::vector<std::pair<int, int>> adds;
		for (int i = 0; i < m; ++i) {
			int a, b;
			std::cin >> a >> b;
			if (used[a][b]) ans = 2;
			used[a][b] = true;
			adds.push_back({a, b});
		}
		std::cout << ans << '\n';
		for (int i = 0; i < adds.size(); ++i) {
			used[adds[i].first][adds[i].second] = false;
		}
	}
}