QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#705329#7900. Gifts from Knowledgeyeah14Compile Error//C++174.9kb2024-11-02 22:58:422024-11-02 22:58:42

Judging History

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

  • [2024-11-02 22:58:42]
  • 评测
  • [2024-11-02 22:58:42]
  • 提交

answer

#include <bits/stdc++.h>
#include <iostream>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define i128 _int128
#define fi first
#define se second 
#define pb push_back
#define endl '\n'
#define int long long

const ll INF = 0x3f3f3f3f;
const ll N = 1e6 + 9;
const int mod = 1e9+7;

// inline int read(){
//     int ans=0,sign=1;
//     char ch = getchar();
//     while(ch<'0'||ch>'9'){
//         if(ch=='-'){
//             sign=-1;
//         }
//         ch=getchar();
//     }
//     while(ch>='0'&&ch<='9'){
//         ans = ans*10 + ch-'0';
//         ch = getchar();
//     }
//     return ans*sign;
// }

int fp(int a, int x, int mod) {
    int ans = 1;
    while (x) {
        if (x & 1)ans *= a%mod;
        a *= a%mod;
        a %= mod;
        x /=2;
    }
    return ans %= mod;
}


int fa[N];
vector<int>cc[N];//第i行为1的
vector<int>rr[N];//第i列为1的
map<int, int>mp;
map<int, int>mpp;
bool p[N];

map<int,int>ans;

int find(int p) {
    if (fa[p] != p)return fa[p] = find(fa[p]);
    else return fa[p];
}

void solve() {

    int r, c;
    cin >> r >> c;
    bool flag = 0;
    char[r + 1][c + 1];
    //初始化
    for (int i = 1; i <= r; i++) {
        fa[i] = i;
        rr[i].clear();
        p[i] = 0;
        
    }
    for (int i = 1; i <= c; i++) {
        cc[i].clear();
    }
    mp.clear();
    mpp.clear();
    ans.clear();
    //
    int cnt = 0;//无影响
    for (int i = 1; i <= r; i++) {
        cin >> s[i]; 
        s[i] = '0' + s[i];  
        for (int j = 1; j <= c; j++) {
            if (s[i][j] == '1') {
                mp[j]++;
                cc[i].push_back(j);
                rr[j].push_back(i);
                if (mp[j] >= 3) {
                    flag = 1;
                }
                
            }
        }
        int len = cc[i].size();
        int l = 0, r = len-1;
        bool ff = 0;
        if (len % 2 == 1 && c % 2 == 1) {
            if (cc[i][(len - 1) / 2] != c / 2)ff = 1;
        }
        else if(len % 2 == 1)ff = 1;
        if (!ff) {
            while (l < r) {
                if (cc[i][l] + cc[i][r] != c)ff = 1;
                l++, r--;
            }
        }
        if (!ff) {
            p[i] = 1;
            cnt++;
            for (int j = 0; j < len; j++) {
                mpp[cc[i][j]]++;
                if (mpp[cc[i][j]] >= 2)flag = 1;
            }
        }
        
    }
    if (flag) {
        cout << 0 << endl;
        return;
    }
    else if (r == 1) {
        cout << 2 << endl;
        return;
    }
    else if (c == 1) {
        if (mp[1] >= 2)cout << 0 << endl;
        else cout << fp(2, r, mod) << endl;
        return;
    }
    else {
        for (int i = 1; i <= c; i++) {
            if (mp[i] >= 2 && mpp.count(i) != 0) {
                for (int j = 0; j < rr[i].size(); j++) {
                    if (p[rr[i][j]])continue;
                    p[rr[i][j]] = 1;
                    int t = rr[i][j];
                    for (int k = 0; k < cc[t].size(); k++) {
                        mp[cc[t][k]]--;
                        mp[c - cc[t][k]]++;
                        mpp[cc[t][k]]++;
                        if (mpp[cc[t][k]] >= 2) {
                            cout << 0 << endl;
                            return;
                        }
                    }
                }
            }
        }
        for (int i = 1; i <= c; i++) {
            if (mp[i] >= 3) {
                cout << 0 << endl;
                return;
            }
        }
        for (int i = 1; i <= r; i++) {
            if (p[i])continue;
            for (int j = 0; j < cc[i].size(); j++) {
                int t = cc[i][j];
                for (int k = 0; k < rr[t].size(); k++) {
                    int tt = rr[t][k];
                    if (p[tt])continue;
                    fa[find(tt)] = find(i);
                }
                t = c-cc[i][j];
                for (int k = 0; k < rr[t].size(); k++) {
                    int tt = rr[t][k];
                    if (p[tt])continue;
                    fa[find(tt)] = find(i);
                }
            }
        }
        int cntt = 0;//无限制块;
        for (int i = 1; i <= r; i++) {
            if (p[i])continue;
            ans[find(i)]++;
            if (ans[find(i)] >= 3) {
                cout << 0 << endl;
                return;
            }
        }
        cntt = ans.size();
        cout << fp(2, cnt, mod) * fp(2, cntt, mod) % mod << endl;
    }
}





signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int _ = 1;
    // fac[0]=1;
    // for(int i=1;i<=N-9;++i)fac[i]=(fac[i-1]*i)%mod;
    cin >> _;

    while (_--)solve();

    return 0;
}


Details

answer.code: In function ‘void solve()’:
answer.code:69:11: error: expected ‘]’ before ‘+’ token
   69 |     char[r + 1][c + 1];
      |           ^~
      |           ]
answer.code:69:9: error: structured binding declaration cannot have type ‘char’
   69 |     char[r + 1][c + 1];
      |         ^
answer.code:69:9: note: type must be cv-qualified ‘auto’ or reference to cv-qualified ‘auto’
answer.code:69:10: error: conflicting declaration ‘auto r’
   69 |     char[r + 1][c + 1];
      |          ^
answer.code:66:9: note: previous declaration as ‘long long int r’
   66 |     int r, c;
      |         ^
answer.code:69:16: error: expected initializer before ‘[’ token
   69 |     char[r + 1][c + 1];
      |                ^
answer.code:86:16: error: ‘s’ was not declared in this scope
   86 |         cin >> s[i];
      |                ^