QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#98776 | #2921. Land Equality | Ahmed_Ghazal | WA | 2ms | 3472kb | C++20 | 2.8kb | 2023-04-20 00:15:06 | 2023-04-20 00:15:07 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ordered_set tree<int, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>
#define iofiles freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout)
#define speed_code ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(c) (c).begin(), (c).end()
#define Sort(c) sort(all(c))
#define speed_code ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define cin(c) for(auto&i:c)cin>>i;
#define cinpair(c) for(auto&i:c)cin>>i.first>>i.second;
#define cout(c) for(auto&i:c)cout<<i<<' '
#define rfor(c) for(auto&i:c)
#define forr(i,n) for (int i = n; i >= 0; --i)
#define coutpair(c) for(auto&i:c)cout<<i.first<<' '<<i.second<<'\n'
#define mems(mem,c) memset(mem,c,sizeof mem)
#define pii pair<int,int>
#define vi vector<int>
#define vs vector<string>
#define vpii vector<pii>
#define td vector<vector<int>>
#define cintd(v) for (size_t i = 0; i < v.size(); i++)for (size_t j = 0; j < v[i].size(); j++)cin>>v[i][j];
#define mpii map<int,int>
#define mpsi map<string,int>
#define mpis map<int,string>
int gcd(int a,int b){
if(!b)return a;
return gcd(b,a%b);
}
int lcm(int a,int b){
return a*b/ gcd(a,b);
}
bool sor(pii& x,pii& y){
return x.second<y.second;
}
int get(int f){
int c=f/2;
int ans=abs(1ll<<c)-(1ll<<(f-c));
return ans;
}
signed main() {
speed_code;
#ifndef ONLINE_JUDGE
iofiles;
#endif
int testcases=1;
// cin>>testcases;
while (testcases--) {
int r,c;cin>>r>>c;
td v(r,vi(c));cintd(v);
int frq[3];
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
frq[v[i][j]]++;
}
}
if(r==1||c==1){
if(r==1){
if(frq[0]>1)cout<<0;
else if(frq[0]==1){
if(v[0][c-1]==1||v[0][0]==1)cout<<1;
else cout<<2;
}
else if(frq[2]%2==0)cout<<0;
else cout<<get(frq[2]);
}
else {
if(frq[0]>1)cout<<0;
else if(frq[0]==1){
if(v[r-1][0]==1||v[0][0]==1)cout<<1;
else cout<<2;
}
else if(frq[2]%2==0)cout<<0;
else cout<<get(frq[2]);
}
continue;
}
if(frq[0]>1)cout<<0;
else if(frq[0]==1){
if(frq[1])cout<<1;
else cout<<2;
}
else if(frq[2]%2==0)cout<<0;
else cout<<get(frq[2]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3472kb
input:
1 2 0 1
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'