Unfortunately we were unable to fully decode your file, as it is not encoded in UTF-8. You can try to decode it yourself by downloading it here.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Micha� Figlus
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<algorithm>

#include "kollib.h"
#include "message.h"

using namespace std;

int main()
{ 
 int n=NumberOfStudents(),k=NumberOfNodes(),z=NumberOfQueries(),i,*t,a,b,c;
 if(MyNodeId()==0)
 { 
     t = new int [n+1];
     t[1]=1;
     b=FirstNeighbor(1);
     t[b]=2;
     a=1; 
     for(i=2;i<n;i++)
     {
         if(FirstNeighbor(b)==a)
         {
             t[SecondNeighbor(b)]=i+1;
             c=SecondNeighbor(b);
         }
         else
         {
             t[FirstNeighbor(b)]=i+1;
             c=FirstNeighbor(b);
         }
         a=b;
         b=c;
     }
     for(i=1;i<=z;i++)
     {
         a=QueryFrom(i);
         b=QueryTo(i);
         printf("%d\n",min(abs(t[a]-t[b]),n-abs(t[a]-t[b])));             
     }          
 }
    
 return 0;
}