CSES - Datatähti 2018 loppu - Results
Submission details
Task:Tanssiaiset
Sender:Leiska
Submission time:2018-01-18 12:31:21 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:17:1: error: stray '\302' in program
 int main()  {
 ^
input/code.cpp:17:1: error: stray '\240' in program
input/code.cpp: In function 'std::pair<int, int> search(int)':
input/code.cpp:10:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v.size(); i++) {
                ^
input/code.cpp: In function 'int main()':
input/code.cpp:31:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i; i<d.size(); i++) {
              ^

Code

#include <bits/stdc++.h>

using namespace std;

int n;
vector<int> v;
vector<int> d;

pair<int,int> search(int x) {
	for(int i=0; i<v.size(); i++) {
		if(v[i]==x)
			return make_pair(v.size(),i);
	}
	return make_pair(-1,-1);
}

int main()  {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i; i<n+1; i++) {
		int t; cin >> t;
		v.push_back(t);
		pair<int,int> x = search(t);
		if(x.first != -1) {
			d.push_back(x.first);
			d.push_back(x.second);
		}
	}

	for(int i; i<d.size(); i++) {
		if( (i>0) && ((d[i] - d[i-1]) == 1)) {
			cout << v[d[i-1]] << " " << v[d[i]] << endl;
		}
	}

	return 0;
}