# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
478849 | MohamedFaresNebili | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 0 ms | 0 KiB |
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")
#pragma GCC target ("avx2")
using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vl = vector<long long>;
#define mp make_pair
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin() , (x).end()
const int N = 2*100005;
const long long MOD = 1000000007;
const long double EPS = 0.000000001;
const double PI = 3.14159265358979323846;
const int nx[4]={1, -1, 0, 0}, ny[4]={0, 0, 1, -1};
long long gcd(int a, int b) { return (b==0?a:gcd(b, a%b)); }
long long lcm(int a, int b) { return a*(b/gcd(a, b)); }
long long fact(int a) { return (a==1?1:a*fact(a-1)); }
int n, arr[124][124];
void solve(int a, int b, int x, int y, int curr) {
if(a==x&&b==y) {
arr[b][a]++; arr[b][a+1]--;
return;
}
if(curr) {
cout<<a<<" "<<b<<" "<<(a+x)/2<<" "<<(b+y)/2<<endl;
int calc; cin>>calc;
int c1=a, c2=b, c3=(a+x)/2, c4=(b+y)/2;
int s=abs(c1-c3+1)*abs(c2-c4+1);
if(calc==s) {
for(int l=c2;l<=c4;l++)
arr[l][c1]++, arr[l][c3+1]--;
}
else if(calc) solve(a, b, (a+x)/2, (b+y)/2, calc);
curr-=calc;
}
if(curr) {
cout<<(a+x)/2+1<<" "<<b<<" "<<x<<" "<<(b+y)/2<<endl;
int calc; cin>>calc;
int c1=(a+x)/2+1, c2=b, c3=x, c4=(b+y)/2;
int s=abs(c1-c3+1)*abs(c2-c4+1);
if(calc==s) {
for(int l=c2;l<=c4;l++)
arr[l][c1]++, arr[l][c3+1]--;
}
else if(calc) solve((a+x)/2+1, b, x, (b+y)/2, calc);
curr-=calc;
}
if(curr) {
cout<<a<<" "<<(b+y)/2+1<<" "<<(a+x)/2<<" "<<y<<endl;
int calc; cin>>calc;
int c1=a, c2=(b+y)/2+1, c3=(a+x)/2, c4=y;
int s=abs(c1-c3+1)*abs(c2-c4+1);
if(calc==s) {
for(int l=c2;l<=c4;l++)
arr[l][c1]++, arr[l][c3+1]--;
}
else if(calc) solve(a, (b+y)/2+1, (a+x)/2, y, calc);
curr-=calc;
}
if(curr) {
int c1=(a+x)/2+1, c2=(b+y)/2+1, c3=x, c4=y;
int s=abs(c1-c3+1)*abs(c2-c4+1);
if(curr==s) {
for(int l=c2;l<=c4;l++)
arr[l][c1]++, arr[l][c3+1]--;
}
else if(curr) solve((a+x)/2+1, (b+y)/2+1, x, y, curr);
}
}
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n; cout<<1<<" "<<1<<" "<<n<<" "<<n<<endl;
int curr; cin>>curr; if(curr) solve(1, 1, n, n, curr);
cout<<"END"<<endl;
for(int l=1;l<=n;l++) {
int cnt=0;
for(int i=1;i<=n;i++)
cout<<cnt+arr[l][i]<<flush, cnt+=arr[l][i];
cout<<endl;
}
return 0;
}