CSES - Datatähti 2015 loppu - Results
Submission details
Task:Ruudukko
Sender:laituli
Submission time:2015-01-29 17:14:41 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:18:40: error: template argument 1 is invalid
   for(set< pair< int, int> i=now.begin();i!=now.end();i++){
                                        ^
input/code.cpp:18:40: error: template argument 2 is invalid
input/code.cpp:18:40: error: template argument 3 is invalid
input/code.cpp:18:42: error: 'i' was not declared in this scope
   for(set< pair< int, int> i=now.begin();i!=now.end();i++){
                                          ^

Code

#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.sync_with_stdio(false);
	int n;
	set< pair < int,int > > next;
	set< pair < int,int > > now;
	char c='Z'+1;
	int m=1;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	now.emplace(pair< int,int> (0,0));
	int x,y;
	while(m<n*2){
		for(set< pair< int, int> i=now.begin();i!=now.end();i++){
			x=(*i).first;
			y=(*i).second;
			if(s[y][x]<c){
				next.clear();
				c=s[y][x];
			}
			if(s[y][x]==c){
				if(x!=n-1){
					next.emplace(pair< int,int> (x+1,y));
				}
				if(y!=n-1){
					next.emplace(pair< int,int> (x,y+1));
                                }
			}
		}
		cout<<c;
		c='Z'+1;
		m++;
		now=next;
		set < pair< int,int> > next;
	}
	cout<<"\n";
	return 0;
}