Posts

Showing posts from March, 2019

POJ Catch That Cow

----------------------- Solution: Version 1 ------------------------------------ // Accepted #include<iostream> #include<vector> #include<cstdio> #include<cmath> #include<queue> #include<map> using namespace std; #define sf scanf #define pf printf #define fast ios_base::sync_with_stdio(false) typedef long long LL; typedef map<LL, LL>mpll; const int high = 1e5+3; const int limit=1e5; const int inf = (1<<31)-1; LL visited[high], level[high]; //mpll visited, level; void CLR() {     for(int i=0; i<high; i++)     {         visited[i]=0;         level[i]=0;     } } void BFS(int x, int K) {     queue<LL>Q;     LL v;     visited[x]=1;     level[x] = 0;     Q.push(x);     while(!Q.empty())     {         LL u = Q.front();         Q.pop();         //cout<<"root=" << u << "\n";         for(int i=0; i<3; i++)         {             if(i==0) v=u-1;             else if(i==1) v=u+1;             else v=u