QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#96355 | #2921. Land Equality | Abdelrahman_ahmed7# | AC ✓ | 2ms | 3544kb | C++17 | 1.7kb | 2023-04-13 20:18:15 | 2023-04-13 20:18:17 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define el '\n'
#define all(a) a.begin(),a.end()
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll N=1e5+5,mod=1e9+7;
ll n ,m ;
bool is_corner_cell(ll x ,ll y)
{
if (n == 1)
{
return x == 0 || x == n-1;
}
if (m == 1)
{
return y == 0 || y == m-1;
}
return false;
}
void solve(ll t) {
cin >> n >> m;
int counts[3] = {0,0,0};
int arr[n][m];
for (ll i = 0 ; i < n ; i ++)
{
for (ll j = 0 ,x ; j < m ; j ++)
{
cin >> x;
arr[i][j] = x;
counts[x]++;
}
}
if (counts[0] >= 2)
{
cout << 0 ;
return;
}
if (counts[0] == 1)
{
if (n == 1 || m == 1)
{
if (arr[0][0] == 1 || arr[n-1][m-1] == 1)
{
cout << 1 ;
return;
}
cout << 2;
return;
}
else
{
if (counts[1] >= 1) {cout << 1; return;}
cout << 2; return;
}
}
// zeros == 0
if (counts[2] % 2 == 0)
{
cout << 0;
return;
}
ll half = counts[2]/2;
long long a = (long long )(1LL << half);
cout << a ;
}
int main() {
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
ll t;
//cin >> t;
t = 1;
for (ll i = 0 ; i < t ; i ++)
{
solve(t);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3468kb
input:
1 2 0 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
1 2 0 2
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
1 2 1 2
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3280kb
input:
2 1 1 1
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3292kb
input:
2 1 0 0
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3336kb
input:
5 5 2 2 2 2 2 2 2 1 2 2 2 1 1 1 2 2 2 1 2 2 2 2 2 2 2
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3336kb
input:
5 5 2 2 2 2 2 2 2 1 2 2 2 1 1 1 2 2 2 1 1 2 2 2 2 2 2
output:
512
result:
ok single line: '512'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3276kb
input:
2 3 0 1 2 1 1 2
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3292kb
input:
2 6 0 2 2 1 2 2 1 1 1 1 2 2
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
4 4 2 2 2 2 2 1 2 2 2 0 2 2 2 2 2 2
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
1 3 0 1 2
output:
2
result:
ok single line: '2'
Test #12:
score: 0
Accepted
time: 2ms
memory: 3336kb
input:
1 6 2 1 2 0 1 2
output:
2
result:
ok single line: '2'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3320kb
input:
6 1 2 1 2 0 1 2
output:
2
result:
ok single line: '2'
Test #14:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
1 5 0 1 1 1 2
output:
2
result:
ok single line: '2'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3296kb
input:
1 6 2 1 2 0 2 1
output:
1
result:
ok single line: '1'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3312kb
input:
1 6 1 1 2 0 1 2
output:
1
result:
ok single line: '1'
Test #17:
score: 0
Accepted
time: 2ms
memory: 3280kb
input:
6 1 2 1 2 0 2 1
output:
1
result:
ok single line: '1'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3296kb
input:
1 10 2 1 1 1 0 0 1 1 1 2
output:
0
result:
ok single line: '0'
Test #19:
score: 0
Accepted
time: 2ms
memory: 3276kb
input:
1 10 1 2 0 2 2 2 2 0 2 1
output:
0
result:
ok single line: '0'
Test #20:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
1 10 0 1 1 1 2 2 1 1 1 0
output:
0
result:
ok single line: '0'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3332kb
input:
8 8 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
output:
2147483648
result:
ok single line: '2147483648'
Test #22:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
0
result:
ok single line: '0'
Test #23:
score: 0
Accepted
time: 2ms
memory: 3304kb
input:
8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
0
result:
ok single line: '0'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3276kb
input:
8 8 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
output:
0
result:
ok single line: '0'
Test #25:
score: 0
Accepted
time: 2ms
memory: 3388kb
input:
7 9 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
output:
2147483648
result:
ok single line: '2147483648'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3280kb
input:
31 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
output:
0
result:
ok single line: '0'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3340kb
input:
1 61 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
output:
1073741824
result:
ok single line: '1073741824'
Test #28:
score: 0
Accepted
time: 2ms
memory: 3388kb
input:
8 8 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 0 0 1 1 1 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 1 0
output:
0
result:
ok single line: '0'
Test #29:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
6 10 0 0 0 1 0 1 1 0 0 0 0 1 0 1 0 0 0 0 1 1 0 1 0 0 1 1 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0
output:
0
result:
ok single line: '0'
Test #30:
score: 0
Accepted
time: 1ms
memory: 3292kb
input:
8 8 2 0 2 2 2 2 2 2 0 2 0 0 0 2 2 2 0 2 2 0 2 2 0 0 0 2 2 2 0 2 0 2 2 2 0 2 0 0 2 0 0 2 0 2 2 0 2 2 0 2 0 0 2 0 2 2 2 2 2 0 0 0 2 2
output:
0
result:
ok single line: '0'
Test #31:
score: 0
Accepted
time: 2ms
memory: 3296kb
input:
10 6 2 0 2 2 0 2 0 0 2 2 0 2 2 2 0 2 0 2 2 2 2 0 2 0 0 0 2 0 0 2 2 2 2 0 2 2 2 0 0 0 2 0 2 2 0 2 0 0 0 2 2 2 0 0 0 0 0 2 2 0
output:
0
result:
ok single line: '0'
Test #32:
score: 0
Accepted
time: 2ms
memory: 3352kb
input:
8 8 1 1 2 1 2 1 1 1 1 2 1 1 2 2 1 1 2 2 1 2 1 2 2 1 1 1 2 2 1 1 1 2 1 2 1 1 2 1 1 1 1 1 1 2 2 1 2 1 1 2 2 1 2 1 2 1 1 2 2 2 2 2 1 1
output:
8192
result:
ok single line: '8192'
Test #33:
score: 0
Accepted
time: 2ms
memory: 3280kb
input:
7 9 2 2 2 2 1 1 1 1 1 1 2 2 2 1 1 2 2 1 1 1 2 1 1 2 2 2 2 2 1 1 1 2 2 2 1 2 2 1 1 1 1 1 2 1 1 2 2 2 2 1 2 2 1 2 2 2 2 2 1 1 1 2 1
output:
65536
result:
ok single line: '65536'
Test #34:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
9 7 2 1 1 1 2 1 2 2 2 1 2 2 1 2 2 1 1 2 1 1 2 1 2 2 2 2 1 2 1 1 1 1 2 2 2 1 2 1 2 2 2 2 1 1 1 1 1 1 1 2 2 2 2 2 2 2 1 2 1 1 2 1 1
output:
65536
result:
ok single line: '65536'
Test #35:
score: 0
Accepted
time: 2ms
memory: 3316kb
input:
8 8 2 1 0 0 2 1 2 2 1 0 0 1 1 0 2 0 1 0 1 2 0 1 0 2 1 2 1 2 1 2 1 2 0 0 1 2 1 0 0 2 0 0 2 1 2 0 2 1 2 1 1 1 1 0 2 0 0 0 1 2 0 1 1 0
output:
0
result:
ok single line: '0'
Test #36:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
7 9 1 1 1 0 2 1 1 2 0 2 1 2 2 2 2 2 0 1 2 0 2 2 0 1 2 0 2 0 2 2 0 0 2 1 1 2 0 0 1 1 1 1 0 1 1 1 2 0 1 1 0 1 1 0 0 2 0 1 2 2 0 0 2
output:
0
result:
ok single line: '0'
Test #37:
score: 0
Accepted
time: 2ms
memory: 3316kb
input:
9 7 2 2 0 2 2 1 2 2 0 2 0 1 1 1 2 1 1 0 1 0 2 0 0 0 1 1 0 1 1 2 1 2 2 2 0 1 2 0 0 0 0 2 1 2 1 0 1 2 2 0 2 2 2 2 0 2 2 0 2 0 2 0 1
output:
0
result:
ok single line: '0'
Test #38:
score: 0
Accepted
time: 1ms
memory: 3336kb
input:
1 64 0 2 1 2 0 1 2 0 2 1 1 2 2 2 2 2 1 2 2 1 2 0 0 1 2 1 1 0 0 2 0 1 1 1 1 1 2 1 2 1 2 0 2 2 0 0 1 1 2 2 1 1 1 1 0 0 2 1 2 2 2 0 2 1
output:
0
result:
ok single line: '0'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3292kb
input:
64 1 1 1 0 0 1 2 0 1 0 1 0 2 2 2 0 2 1 1 2 1 0 0 2 0 0 1 2 0 1 0 0 2 1 1 0 2 2 0 2 0 1 0 0 1 2 1 0 1 1 2 2 0 1 1 0 0 0 0 2 0 2 1 1 2
output:
0
result:
ok single line: '0'
Test #40:
score: 0
Accepted
time: 0ms
memory: 3384kb
input:
2 32 0 2 2 2 2 1 1 1 2 1 1 2 1 1 2 0 1 1 2 2 2 2 0 0 0 0 0 1 2 1 0 2 0 1 2 2 2 1 1 1 0 0 1 2 2 2 0 0 0 1 1 2 0 0 1 2 2 0 0 2 2 0 2 0
output:
0
result:
ok single line: '0'
Test #41:
score: 0
Accepted
time: 2ms
memory: 3284kb
input:
32 2 1 0 1 2 2 0 0 1 0 0 0 2 1 0 1 1 0 2 1 0 1 1 2 0 1 1 1 2 2 0 1 1 0 0 2 0 2 1 1 2 0 2 2 0 0 1 1 2 0 1 1 1 1 1 0 0 2 2 0 1 0 0 2 0
output:
0
result:
ok single line: '0'
Test #42:
score: 0
Accepted
time: 2ms
memory: 3332kb
input:
1 63 1 1 1 2 0 1 1 1 2 1 1 1 2 1 2 2 1 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 2 2 1 2 2 1 1 2 2 2 1 2 2 1 2 1 2 2 1 1 2 2 1 1 2 2 2 2 1 1 1
output:
1
result:
ok single line: '1'
Test #43:
score: 0
Accepted
time: 2ms
memory: 3300kb
input:
1 64 1 2 1 2 2 1 1 1 0 2 1 1 2 1 2 2 2 2 1 1 1 2 1 2 1 2 1 1 1 2 1 2 1 1 1 2 2 2 1 2 2 2 2 2 1 2 1 1 2 2 1 1 2 2 2 2 2 1 2 2 1 2 1 2
output:
1
result:
ok single line: '1'
Test #44:
score: 0
Accepted
time: 1ms
memory: 3292kb
input:
63 1 1 1 1 1 2 1 1 1 1 2 2 1 1 2 2 2 2 1 2 2 2 1 1 1 1 2 2 1 2 1 2 1 1 1 2 1 1 2 2 2 2 1 1 1 2 1 2 1 2 2 1 1 2 1 1 0 1 2 2 1 1 1 1
output:
1
result:
ok single line: '1'
Test #45:
score: 0
Accepted
time: 0ms
memory: 3384kb
input:
64 1 2 1 2 1 2 1 1 1 1 2 2 1 2 2 2 1 2 1 1 1 2 1 2 1 2 2 2 2 1 1 1 2 2 1 2 0 1 1 2 2 2 2 2 2 2 2 1 2 2 1 1 2 2 2 1 2 2 2 2 1 1 1 1 2
output:
2
result:
ok single line: '2'
Test #46:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
8 8 2 1 1 2 1 1 2 2 1 1 1 1 1 1 2 1 1 2 2 1 2 2 2 1 1 2 1 1 1 2 2 0 1 1 1 1 2 1 1 1 2 1 2 2 2 2 1 1 1 2 2 1 1 2 1 1 1 2 1 2 2 1 2 2
output:
1
result:
ok single line: '1'
Test #47:
score: 0
Accepted
time: 0ms
memory: 3296kb
input:
2 32 2 1 1 2 0 2 2 2 1 1 2 1 2 2 1 1 2 1 2 2 2 1 1 2 2 1 1 1 2 2 2 1 1 1 1 2 2 2 2 2 1 2 2 1 1 2 1 2 2 2 1 1 2 1 2 2 2 1 2 1 2 1 2 2
output:
1
result:
ok single line: '1'
Test #48:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
32 2 2 2 1 1 2 1 1 1 2 1 1 2 1 1 1 1 1 2 2 2 1 1 2 1 1 1 2 1 1 1 1 1 2 1 1 2 1 2 1 1 1 2 1 0 1 2 1 1 1 1 2 1 2 1 2 1 1 2 2 2 1 2 2 2
output:
1
result:
ok single line: '1'
Test #49:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
3 4 1 2 1 1 2 2 1 2 1 2 2 2
output:
8
result:
ok single line: '8'
Test #50:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
2 3 0 1 2 0 1 2
output:
0
result:
ok single line: '0'
Test #51:
score: 0
Accepted
time: 0ms
memory: 3332kb
input:
1 3 2 0 2
output:
2
result:
ok single line: '2'