QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#98777#2921. Land EqualityAhmed_GhazalWA 2ms3416kbC++202.8kb2023-04-20 00:16:322023-04-20 00:16:33

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-20 00:16:33]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3416kb
  • [2023-04-20 00:16:32]
  • 提交

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;
}


















详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3416kb

input:

1 2
0 1

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'