Created
June 29, 2015 13:53
-
-
Save rogerioagjr/6ca46797fbf53b720705 to your computer and use it in GitHub Desktop.
Caça ao Tesouro (Roger Benet)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <algorithm> | |
#define MAX 110 | |
using namespace std; | |
int mapa[MAX][MAX]; | |
int n,k; | |
int main(){ | |
scanf("%d %d", &n, &k); | |
for(int i = 0; i < k; i++){ | |
int a,b,c,sa,sb,cont; | |
scanf("%d %d %d", &a, &b, &c); | |
for(int i = 0; i < n; i++){ | |
for(int j = 0; j < n; j++){ | |
if( abs(i-a) + abs(j-b) == c ){ | |
mapa[i][j]++; | |
} | |
} | |
} | |
} | |
bool ver = false; | |
int x = -1,y = -1; | |
for(int i = n-1; i > -1; i--){ | |
for(int j = n-1; j > -1; j--){ | |
if(mapa[i][j] == k){ | |
if(x != -1){ | |
ver = true; | |
break; | |
} | |
x = i; | |
y = j; | |
} | |
} | |
} | |
if(ver == false)printf("%d %d\n",x,y); | |
else printf("-1 -1\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment