QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601760#8507. Clever Cell ChoicesForever_Young#Compile Error//C++232.6kb2024-09-30 12:45:002024-09-30 12:45:00

Judging History

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

  • [2024-09-30 12:45:00]
  • 评测
  • [2024-09-30 12:45:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define R register int
#define AC 110
#define ac 81000

int n, m, num;
int Head[ac], Next[ac], date[ac], tot;
int link[ac], match[ac], id[AC][AC], a[6] = {-1, 1, 0, 0}, b[6] = {0, 0, -1, 1};
char s[AC][AC];
bool vis[ac], z[ac];

struct node{int x, y;}back[ac];

inline void add(int f, int w)
{
    date[++ tot] = w, Next[tot] = Head[f], Head[f] = tot;
    date[++ tot] = f, Next[tot] = Head[w], Head[w] = tot;
}

bool dfs(int x)
{
    for(R i = Head[x]; i; i = Next[i])
    {
        int now = date[i];
        if(vis[now]) continue;
        vis[now] = true;
        if(!link[now] || dfs(link[now])) 
        {
            link[now] = x, match[x] = now; 
            return 1;
        }
    }
    return 0;
}

void cal()
{
    memset(link, 0, sizeof(link));
    for(R i = 1; i <= num; i ++)
    {
        if(!(i & 1)) continue;
        memset(vis, 0, sizeof(vis)), dfs(i);
    }	
}

void pre()
{
    scanf("%d%d", &n, &m), num = n * m;
    for(R i = 1; i <= n; i ++) scanf("%s", s[i] + 1);
    int tmp1 = 1, tmp2 = 2;
    for(R i = 1; i <= n; i ++)
    {
        for(R j = 1; j <= m; j ++)
        {
            if((i + j) & 1) id[i][j] = tmp2, back[tmp2] = (node){i, j}, tmp2 += 2;
            else id[i][j] = tmp1, back[tmp1] = (node){i, j}, tmp1 += 2;
        }
    }
    
    for(R i = 1; i <= n; i ++)
        for(R j = 1; j <= m; j ++)
        {
            if(s[i][j] == '#') continue;
            for(R k = 0; k <= 3; k ++)
            {
                int x = i + a[k], y = j + b[k];
                if(x <= 0 || x > n || y <= 0 || y > m || s[x][y] == '#') continue;
                int s = id[i][j], t = id[x][y];
                (s & 1) ? add(s, t) : add(t, s);
            }
        }
}

void dfs1(int x)
{
    if(z[x]) return ;
    z[x] = true;
    for(R i = Head[x]; i; i = Next[i]) dfs1(link[date[i]]);
}

void dfs2(int x)
{
    if(z[x]) return ;
    z[x] = true;
    for(R i = Head[x]; i; i = Next[i]) dfs2(match[date[i]]);
}

void work()
{
    for(R i = 1; i <= num; i ++) 
    {
        if(s[back[i].x][back[i].y] == '#') continue;
        if((i & 1) && !match[i]) dfs1(i);
        else if(!(i & 1) && !link[i]) dfs2(i);
    }
    bool done = false;
    for(R i = 1; i <= n; i ++)
        for(R j = 1; j <= m; j ++)
            if(z[id[i][j]]) {done = true; break;}
    if(!done) {printf("0\n"); return ;}
    int ans=0;
    for(R i = 1; i <= n; i ++) 
        for(R j = 1; j <= m; j ++)
            if(z[id[i][j]]) ans++;
    printf("%d\n",ans);
}

int main()
{
    pre();
    cal();
    work();
    return 0;
}

詳細信息

answer.code:9:12: error: ‘int link [81000]’ redeclared as different kind of entity
    9 | int link[ac], match[ac], id[AC][AC], a[6] = {-1, 1, 0, 0}, b[6] = {0, 0, -1, 1};
      |            ^
In file included from /usr/include/c++/13/bits/atomic_wait.h:44,
                 from /usr/include/c++/13/bits/atomic_base.h:42,
                 from /usr/include/c++/13/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/13/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56,
                 from answer.code:1:
/usr/include/unistd.h:789:12: note: previous declaration ‘int link(const char*, const char*)’
  789 | extern int link (const char *__from, const char *__to)
      |            ^~~~
answer.code: In function ‘bool dfs(int)’:
answer.code:23:11: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   23 |     for(R i = Head[x]; i; i = Next[i])
      |           ^
answer.code:28:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |         if(!link[now] || dfs(link[now]))
      |                     ^
answer.code:28:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |         if(!link[now] || dfs(link[now]))
      |                                      ^
answer.code:28:38: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ to ‘int’ [-fpermissive]
   28 |         if(!link[now] || dfs(link[now]))
      |                              ~~~~~~~~^
      |                                      |
      |                                      int (*)(const char*, const char*) noexcept
answer.code:21:14: note:   initializing argument 1 of ‘bool dfs(int)’
   21 | bool dfs(int x)
      |          ~~~~^
answer.code:30:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |             link[now] = x, match[x] = now;
      |                     ^
answer.code:30:23: error: assignment of read-only location ‘*(link + ((sizetype)now))’
   30 |             link[now] = x, match[x] = now;
      |             ~~~~~~~~~~^~~
answer.code: In function ‘void cal()’:
answer.code:39:28: error: ISO C++ forbids applying ‘sizeof’ to an expression of function type [-fpermissive]
   39 |     memset(link, 0, sizeof(link));
      |                           ~^~~~~
answer.code:39:12: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ to ‘void*’ [-fpermissive]
   39 |     memset(link, 0, sizeof(link));
      |            ^~~~
      |            |
      |            int (*)(const char*, const char*) noexcept
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/c++config.h:679,
                 from /usr/include/c++/13/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:33:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 1 of ‘void* memset(void*, int, size_t)’
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
answer.code:40:11: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   40 |     for(R i = 1; i <= num; i ++)
      |           ^
answer.code: In function ‘void pre()’:
answer.code:50:11: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   50 |     for(R i = 1; i <= n; i ++) scanf("%s", s[i] + 1);
      |           ^
answer.code:52:11: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   52 |     for(R i = 1; i <= n; i ++)
      |           ^
answer.code:54:15: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   54 |         for(R j = 1; j <= m; j ++)
      |               ^
answer.code:61:11: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   61 |     for(R i = 1; i <= n; i ++)
      |           ^
answer.code:62:15: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   62 |         for(R j = 1; j <= m; j ++)
      |               ^
answer.code:65:19: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   65 |             for(R k = 0; k <= 3; k ++)
      |                   ^
answer.code: In function ‘void dfs1(int)’:
answer.code:79:11: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   79 |     for(R i = Head[x]; i; i = Next[i]) dfs1(link[date[i]]);
      |           ^
answer.code:79:57: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   79 |     for(R i = Head[x]; i; i = Next[i]) dfs1(link[date[i]]);
      |                                                         ^
answer.code:79:57: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ to ‘int’ [-fpermissive]
   79 |     for(R i = Head[x]; i; i = Next[i]) dfs1...