QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#98779 | #2921. Land Equality | Ahmed_Ghazal | WA | 2ms | 3460kb | C++20 | 3.0kb | 2023-04-20 00:19:59 | 2023-04-20 00:20:00 |
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<<'\n';
}
else if(frq[0]==1){
if(v[0][c-1]==1||v[0][0]==1)cout<<1<<'\n';
else cout<<2<<'\n';
}
else if(frq[2]%2==0)cout<<0<<'\n';
else cout<<get(frq[2])<<'\n';
}
else {
if(frq[0]>1){
cout<<0<<'\n';
}
else if(frq[0]==1){
if(v[r-1][0]==1||v[0][0]==1)cout<<1<<'\n';
else cout<<2<<'\n';
}
else if(frq[2]%2==0)cout<<0<<'\n';
else cout<<get(frq[2])<<'\n';
}
continue;
}
if(frq[0]>1){
cout<<0<<'\n';
}
else if(frq[0]==1){
if(frq[1])cout<<1<<'\n';
else cout<<2<<'\n';
}
else if(frq[2]%2==0)cout<<0<<'\n';
else cout<<get(frq[2])<<'\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3452kb
input:
1 2 0 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3460kb
input:
1 2 0 2
output:
2
result:
ok single line: '2'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3360kb
input:
1 2 1 2
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'