Skip to content

Instantly share code, notes, and snippets.

@peryaudo
Created December 19, 2010 07:50
Show Gist options
  • Save peryaudo/747189 to your computer and use it in GitHub Desktop.
Save peryaudo/747189 to your computer and use it in GitHub Desktop.
#include <cstdio>
inline int colour(int N, int a, int b){
if(a > N / 2) a = N - a + 1;
if(b > N / 2) b = N - b + 1;
if(a > b){
int t = a;
a = b;
b = t;
}
return ((a - 1) % 3) + 1;
}
int main()
{
int N, K;
scanf("%d\n%d\n", &N, &K);
for(int i = 0; i < K; i++){
int a, b;
scanf("%d %d\n", &a, &b);
printf("%d\n", colour(N, a, b));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment