Skip to content

Instantly share code, notes, and snippets.

@kitayuta
Created December 19, 2010 07:46
Show Gist options
  • Save kitayuta/747185 to your computer and use it in GitHub Desktop.
Save kitayuta/747185 to your computer and use it in GitHub Desktop.
2011 JOI yosen Problem 3
#include<cstdio>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<iostream>
#include<sstream>
using namespace std;
typedef long long ll;
int main(){
int n,k;
scanf("%d%d",&n,&k);
for(int i=0;i<k;i++){
int a,b;
scanf("%d%d",&a,&b);
if(a>(n+1)/2)a-=a*2-(n+1);
if(b>(n+1)/2)b-=b*2-(n+1);
int mi=min(a,b)%3;
if(mi==0)mi=3;
printf("%d\n",mi);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment