Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <cctype>
- #include <cmath>
- #include <cstring>
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <list>
- #include <stack>
- #include <queue>
- #include <map>
- #include <set>
- #include <string>
- #include <utility>
- #include <sstream>
- #include <algorithm>
- #include <ctime>
- #include <cassert>
- #include <limits>
- using namespace std;
- #define PI acos(-1.0)
- #define mem(a,b) memset(a,b,sizeof(a))
- #define gcd(a,b) __gcd(a,b)
- #define pb push_back
- #define mp make_pair
- #define x first
- #define y second
- #define Sort(x) sort(x.begin(),x.end())
- #define FOR(i, b, e) for(int i = b; i <= e; i++)
- #define FORR(i, b, e) for(int i = b; i >= e; i--)
- #define FORI(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
- #define pr(x) cout<<x<<"\n"
- #define pr2(x,y) cout<<x<<" "<<y<<"\n"
- #define pr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
- #define ppr(a) cout<<a.x<<" "<<a.y<<"\n"
- #define READ(f) freopen(f, "r", stdin)
- #define WRITE(f) freopen(f, "w", stdout)
- typedef long long ll;
- typedef pair <int, int> pii;
- typedef pair <double , double> pdd;
- typedef pair <ll , ll > pll;
- typedef vector <int> vi;
- typedef vector <pii> vpii;
- typedef vector <ll > vl;
- //int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
- //int dx[]={1,1,0,-1,-1,-1,0,1};
- //int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
- //int dx[]={2,1,-1,-2,-2,-1,1,2};
- //int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
- #define MAX 100007
- #define EPS 1e-9
- bool v[505][505][1005];
- struct BearPlaysDiv2{
- string equalPiles(int A, int B, int C)
- {
- string ret="possible";
- mem(v,false);
- if((A+B+C)%3==0&&posi(A,B,C)) ret="possible";
- else ret="impossible";
- return ret;
- }
- bool posi(int a,int b,int c)
- {
- vi ar;
- ar.pb(a);
- ar.pb(b);
- ar.pb(c);
- Sort(ar);
- if(ar[0]==ar[1]&&ar[1]==ar[2])return 1;
- if(v[ar[0] ][ar[1] ][ar[2] ])return 0;
- //if(ar[0]==3&&ar[1]==498)pr3(a,b,c);
- v[ar[0] ][ar[1] ][ar[2] ]=true;
- int ans=0;
- if(ar[0]!=ar[1])
- {
- // if(ar[0]==480&&ar[1]==483)pr3(a,b,c);
- ans+=posi(2*ar[0],ar[1]-ar[0],ar[2]);
- }
- if(ar[0]!=ar[2])
- ans+=posi(2*ar[0],ar[1],ar[2]-ar[0]);
- if(ar[1]!=ar[2])
- ans+=posi(ar[0],2*ar[1],ar[2]-ar[1]);
- return (ans!=0);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement