This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define int long long
typedef long double ld;
typedef string str;
template<typename T>
using v=vector<T>;
typedef vector<int> vint;
typedef vector<bool> vbool;
typedef vector<str> vstr;
#define hmap unordered_map
#define hset unordered_set
#define e5 100001
#define mod 1000000007
#define mod2 36028797018963913 //2^55-55
#define rep(a,l,r) for(long long a=(l);a<(r);a++)
#define eol put endl
#define ednl endl
#define sz(a) ((long long)(a).size())
#define len(a) ((long long)(a).length())
#define add push_back
const str alphabetLower ="abcdefghijklmnopqrstuvwxyz";
const str alphabetHigher="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const str digits="0123456789";
const long double pi=3.141592653589793,e=2.718281828459045;
void read(){}void print(){}void debug(){cerr<<endl;}
int gcd(int a,int b){
if(a<0)a=abs(a);if(b<0)b=abs(b);
if (a>b)swap(a,b);
if (a)return gcd(a,b%a);
return b;
}
int lcm(int a,int b){return a/gcd(a,b)*b;}
struct vt{
int x,y;
vt operator-(){return vt(-this->x,-this->y);}
vt operator+(vt b){return {this->x+b.x,this->y+b.y};}
vt operator-(vt b){return *this+(-b);}
vt operator*(int b){return vt(this->x*b,this->y*b);}
int operator*(vt b){return this->x*b.x+this->y*b.y;}
vt operator/(int b){return vt(this->x/b,this->y/b);}
int operator%(vt b){return this->x*b.y - b.x*this->y;}
bool operator==(vt b){return this->x==b.x&&this->y==b.y;}
bool operator!=(vt b){return !((*this)==b);}
bool collinear(vt b){return (*this)%b==0;}
bool opposite(vt b){return this->collinear(b)&&(*this)*b<0;}
double length(){return sqrt(this->x*this->x+this->y*this->y);}
vt(){}
vt(int x,int y):x(x),y(y){}
vt(int x1,int y1,int x2,int y2):x(x2-x1),y(y2-y1){}
};
int fact(int a){if (a==1)return 1;else return a*fact(a-1);}
int sign(int a){if(a>0)return 1;if(a==0)return 0;return -1;}
bool prime(int a){
if(a<2)return 0;if(a==2)return 1;
for(int b=2;b<=ceil(sqrt(a));b++)if(a%b==0)return 0;
return 1;
}
int hashStr(str& s){
int base=26;
int res=0;
for(int i=0;i<len(s);i++)res=((res*base)%mod2+s[i]-'a'+1)%mod2;
return (res+mod2)%mod2;
}
int hashStr(int prevHash,char curChar){return ((prevHash*26)%mod2+curChar-'a'+1)%mod2;}
struct node{
node*left=nullptr,*right=nullptr;
int w,val,sz=1;
node(int val):w((rand()<<16)+rand()),val(val){}
};
int siz(node*a){
if(a==nullptr)return 0;
else return a->sz;
}
node* treap;
node* merge1(node* v1,node* v2){
if(v1==nullptr)return v2;
if(v2==nullptr)return v1;
if(v1->w>v2->w){
v1->right=merge1(v1->right,v2);
v1->sz=siz(v1->left)+siz(v1->right)+1;
return v1;
} else {
v2->left=merge1(v1,v2->left);
v2->sz=siz(v2->left)+siz(v2->right)+1;
return v2;
}
}
pair<node*,node*> split(node* w,int k){
if(w==nullptr)return {nullptr,nullptr};
if(siz(w->left)>=k){
auto tmp=split(w->left,k);
w->left=tmp.second;
w->sz=siz(w->left)+siz(w->right)+1;
return {tmp.first,w};
} else {
auto tmp=split(w->right,k-siz(w->left)-1);
w->right=tmp.first;
w->sz=siz(w->left)+siz(w->right)+1;
return {w,tmp.second};
}
}
ifstream fin ("input.txt" );
ofstream fout("output.txt");
#if 0 //FileIO
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
template<typename Arg,typename... Args>void read(Arg& arg,Args&... args){get arg;read(args...);}
template<typename Arg,typename... Args>void print(Arg arg,Args... args){put (arg)<<" ";print(args...);}
template<typename Arg,typename... Args>void debug(Arg arg,Args... args){cerr<<(arg)<<" ";debug(args...);}
void prnt(node* a){
if(a==nullptr)return;
prnt(a->left);
print(a->val);
prnt(a->right);
}
//code goes here
int calc(v<char>* s){
int tot=0,dmg=1;
for(int i=0;i<(int)s->size();i++){
if(s->at(i)=='C')dmg*=2;
else tot+=dmg;
}
return tot;
}
void run(){
int t;get t;
rep(test,1,t+1){
int a;get a;
int n=(a==200?20:5),m=(a==200?10:4);
bool mat[n][m];rep(i,0,n)rep(j,0,m)mat[i][j]=0;
while(1){
int mn=10,x=0,y=0;
rep(i,1,n-1)rep(j,1,m-1){
int s=0;
if(mat[i-1][j-1])s++;
if(mat[i-1][j])s++;
if(mat[i-1][j+1])s++;
if(mat[i][j-1])s++;
if(mat[i][j])s++;
if(mat[i][j+1])s++;
if(mat[i+1][j-1])s++;
if(mat[i+1][j])s++;
if(mat[i+1][j+1])s++;
if(mn>s){mn=s;x=i;y=j;}
}
print(x+10,y+10);eol;
int i,j;read(i,j);
if(i==0||j==0)break;
mat[i-10][j-10]=1;
}
}
}
int32_t main() {ios::sync_with_stdio(false);cin.tie(0);run();return 0;}
Compilation message (stderr)
gogopher.cpp: In function 'long long int gcd(long long int, long long int)':
gogopher.cpp:29:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(a<0)a=abs(a);if(b<0)b=abs(b);
^~
gogopher.cpp:29:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(a<0)a=abs(a);if(b<0)b=abs(b);
^~
gogopher.cpp: In function 'bool prime(long long int)':
gogopher.cpp:57:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(a<2)return 0;if(a==2)return 1;
^~
gogopher.cpp:57:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(a<2)return 0;if(a==2)return 1;
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |