Witam mam problem z zadaniem na polskim SPOJ'u.
zadanie: http://pl.spoj.com/problems/FR_03_04/
Uznałem, że zmapuje współrzędne i porównam ze współrzędnymi spadochroniarzy.
Debugując i sprawdzając dane złapałem jeden błąd.
4
0 1
3 4
1 0
0 5
6
0 1
NIE
3 4
TAK
1 0
TAK
0 5
TAK
5 0
NIE
0 1
NIE
Gdzie dla danych bez początkowych zer jest poprawnie
5
5 7
2 3
3 1
6 7
88 65
7
5 7
TAK
2 3
TAK
3 5
NIE
3 1
TAK
6 7
TAK
88 65
TAK
99 64
NIE
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <unordered_map>
using std::endl;
using std::cin;
using std::cout;
using std::string;
using std::vector;
using std::unordered_map;
#define VAR(c, x) __typeof(x) c = x
#define FOREACH(i, c) for(VAR(i, c.begin()); i!=c.end(); i++)
typedef unordered_map<int, int> mapa;
//bool check(mapa & v, int x, int y){ nie wiem dlaczego, ale po odznaczeniu i użyciu funkcji wyskakuje błąd error: request for member 'first' in '* i.__gnu_cxx::__normal_iterator<_Iterator...
// FOREACH(i, v)
// if(i->first == x && i->second == y)
// return true;
// return false;
//}
int main(void){
int t, x, y;
bool check = 0;
mapa position;
cin>>t;
while(t--){
cin>>x>>y;
position[x] = y;
}
cin>>t;
while(t--){
cin>>x>>y;
FOREACH(i, position)
if(i-> first == x && i->second == y)
check = 1;
if(check){
cout<<"TAK\n";
check = 0;
}
else
cout<<"NIE\n";
}
}
Czy mógłby ktoś wytłumaczyć powyższe błedy oraz doradzić, gdzie robię źle!?