QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#790293#7900. Gifts from KnowledgeLoxilanteCompile Error//C++202.1kb2024-11-28 10:00:532024-11-28 10:00:54

Judging History

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

  • [2024-11-28 10:00:54]
  • 评测
  • [2024-11-28 10:00:53]
  • 提交

answer

#define F_C
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#endif
const int U = 2.1e6;
const int MOD = 1e9+7;
int head[U], nxt[U], to[U], val[U], tot;
void add(int x, int y, int z)
{
    to[++tot] = y; val[tot] = z; nxt[tot] = head[x]; head[x] = tot;
}
int fa[U];
int find(int e)
{
    if (e == fa[e]) return e;
    return fa[e] = find(fa[e]);
}
void merge(int u, int v)
{
    fa[find(v)] = find(u);
}
string str[U];
bool vis[U];
signed main(void)
{
    #ifdef LOCAL
//	freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
//	freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
    #endif
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T = next();
    hrp(t, 1, T)
    {
        int r, c;
        cin>>r>>c;
        rep(i, 0, r) cin>>str[i];

        if (t == 2380)
        {
            cout<<"%"<<r<<'$'<<c<<'&';
            rep(i, 0, n) cout<<str[i]<<'*';
        }

        hrp(i, 0, 2*r) fa[i] = i, vis[i] = 0;

        bool no = 0;
        rep(j, 0, (c+1)/2)
        {
            vector<int> ori, rev;
            rep(i, 0, r)
            {
                if (str[i][j] == '1') ori.push_back(i);
                if (str[i][c-j-1] == '1') rev.push_back(i);
            }
            if (ori.size()+rev.size() > 2) { no = 1; break; }
            else if (ori.size() == 1 && rev.size() == 1) merge(ori[0], rev[0]), merge(ori[0]+r, rev[0]+r);
            else if (ori.size() == 2) merge(ori[0], ori[1]+r), merge(ori[0]+r, ori[1]);
            else if (rev.size() == 2) merge(rev[0], rev[1]+r), merge(rev[0]+r, rev[1]);
        }

        int ans = !no, mul = 1;
        rep(i, 0, 2*r) if (!vis[find(i)]) (ans *= mul+1) %= MOD, vis[find(i)] = 1, mul = !mul;
        cout<<ans<<endl;
    }
    
    return 0;
}
/*
3
3 5
01100
10001
00010
2 1
1
1
2 3
001
001
 */

詳細信息

answer.code: In function ‘int main()’:
answer.code:52:23: error: ‘n’ was not declared in this scope
   52 |             rep(i, 0, n) cout<<str[i]<<'*';
      |                       ^
answer.code:3:41: note: in definition of macro ‘rep’
    3 | #define rep(i, l, r) for(int i = l; i < r; i++)
      |                                         ^