比赛 2026.4.11 评测结果 AAAAAEEEEE
题目名称 与或和 最终得分 50
用户昵称 梦那边的美好ME 运行时间 1.180 s
代码语言 C++ 内存使用 3.53 MiB
提交时间 2026-04-11 12:32:19
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1000000007;

int n;
int g[105][105];
int ra[105];
int ro[105];

int main(){
    freopen("andorsum.in","r",stdin);
    freopen("andorsum.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            cin>>g[i][j];
        }
    }
    ll sa=0,so=0;
    for (int r1=1;r1<=n;r1++){
        for (int r2=r1;r2<=n;r2++){
            for (int j=1;j<=n;j++){
                if (r1==r2){
                    ra[j]=g[r2][j];
                    ro[j]=g[r2][j];
                } else {
                    ra[j]&=g[r2][j];
                    ro[j]|=g[r2][j];
                }
            }
            for (int c1=1;c1<=n;c1++){
                int ca=ra[c1];
                int co=ro[c1];
                for (int c2=c1;c2<=n;c2++){
                    ca&=ra[c2];
                    co|=ro[c2];
                    sa=(sa+ca)%mod;
                    so=(so+co)%mod;
                }
            }
        }
    }
    cout<<sa<<" "<<so<<'\n';
    return 0;
}