QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524256#5668. Cell Nuclei Detectionucup-team3699#Compile Error//C++143.7kb2024-08-19 14:23:562024-08-19 14:23:56

Judging History

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

  • [2024-08-19 14:23:56]
  • 评测
  • [2024-08-19 14:23:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 50005;
const int inf = 1e9;
struct dinic{
    int s, t;
    int n;
    void init(int _n, int t1, int t2){
        s = t1, t = t2;  n = _n;
    }
    struct Edge{
        int to, cap, flow;
    };
    vector<Edge>edge;
    vector<int> node[N + 5];
    int cur[N + 5], dep[N + 5];

    void add(int g, int h, int c){
        node[g].push_back(edge.size());
        edge.push_back({h, c, 0});
        node[h].push_back(edge.size());
        edge.push_back({g, 0, 0});
    }
    bool bfs(){
        queue<int> now;
        int vis[n + 1] = {0};
        for(int i = 0; i < n; i++){
            cur[i] = 0;
            dep[i] = 0;
        }
        now.push(s);
        vis[s] = 1;
        dep[s] = 1;
        while(now.size()){
            int tt = now.front();
            now.pop();
            for(int &i = cur[tt]; i < node[tt].size(); i++){
                int t1 = edge[node[tt][i]].to;
                int t2 = edge[node[tt][i]].cap;
                int t3 = edge[node[tt][i]].flow;
                if(!vis[t1] && t2 > t3){
                    dep[t1] = dep[tt] + 1;
                    vis[t1] = 1;
                    now.push(t1);
                }
            }
        }
        return vis[t];
    }
    int dfs(int v, int tot){

        if(v == t || tot == 0) return tot;
        int ff = 0;
        for(int &i = cur[v]; i < node[v].size(); i++){
            int t1 = edge[node[v][i]].to;
            int t2 = edge[node[v][i]].cap;
            int t3 = edge[node[v][i]].flow;
            if(t2 > t3 && dep[t1] == dep[v] + 1){
                int g = dfs(t1, min(tot - ff, t2 - t3));
                ff += g;
                edge[node[v][i]].flow += g;
                edge[node[v][i] ^ 1].flow -= g;
                if(ff == tot)
                    return ff;
            }
        }
        if(ff == 0)
            dep[v] = 0;
        
        return ff;
    }
    int flow(){
        int ans = 0;
        while(bfs()){
            for(int i = 0; i < n; i++){
                cur[i] = 0;
            }
            ans += dfs(s, inf);
        }
        return ans;
    }
};
int x1[N << 1], y1[N << 1], x2[N << 1], y2[N << 1];
vector<int> have[2005][2005];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--){
        for(int i = 0; i <= 2000; i++){
            for(int j = 0; j <= 2000; j++){
                have[i][j].clear();
            }
        }

        int n, m;
        cin >> n >> m;
        dinic din;
        din.init(n + m + 2, 0, n + m + 1);
        for(int i = 1; i <= n; i++){
            cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        }
        for(int i = n + 1; i <= n + m; i++){
            cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        }
        for(int i = n + 1; i <= n + m; i++){
            din.add(i, n + m + 1, 1);
            for(int j = x1[i]; j < x2[i]; j++){
                for(int k = y1[i]; k < y2[i]; k++){
                    have[j][k].push_back(i);
                }
            }
        }
        for(int i = 1; i <= n; i++){
            din.add(0, i, 1);
            map<int, int> cnt;
            for(int j = x1[i]; j < x2[i]; j++){
                for(int k = y1[i]; k < y2[i]; k++){
                    for(auto p : have[j][k]){
                        cnt[p] += 1;
                    }
                }
            }
            for(auto p : cnt){
                if(p.second * 2 >= (x2[i] - x1[i]) * (y2[i] - y1[i])){
                    din.add(i, p.first, 1);
                }
            }
        }
        cout << din.flow() << '\n';
    }
}

详细

answer.code:83:26: error: ‘int y1 [100010]’ redeclared as different kind of entity
   83 | int x1[N << 1], y1[N << 1], x2[N << 1], y2[N << 1];
      |                          ^
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,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration ‘double y1(double)’
  221 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:102:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  102 |             cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |                                 ^
answer.code:102:26: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘double(double) throw ()’ {aka ‘double(double)’})
  102 |             cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |             ~~~~~~~~~~~~ ^~ ~~~~~
      |                 |               |
      |                 |               double(double) throw () {aka double(double)}
      |                 std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127:
/usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:102:33: error: invalid conversion from ‘double (*)(double) throw ()’ {aka ‘double (*)(double)’} to ‘void*’ [-fpermissive]
  102 |             cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |                             ~~~~^
      |                                 |
      |                                 double (*)(double) throw () {aka double (*)(double)}
answer.code:102:33: error: cannot bind rvalue ‘(void*)(y1 + ((sizetype)i))’ to ‘void*&’
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:102:33: error: invalid conversion from ‘double (*)(double) throw ()’ {aka ‘double (*)(double)’} to ‘long long unsigned int’ [-fpermissive]
  102 |             cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |                             ~~~~^
      |                                 |
      |                                 double (*)(double) throw () {aka double (*)(double)}
answer.code:102:33: error: cannot bind rvalue ‘(long long unsigned int)(y1 + ((sizetype)i))’ to ‘long long unsigned int&’
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:102:33: error: invalid conversion from ‘double (*)(double) throw ()’ {aka ‘double (*)(double)’} to ‘long long int’ [-fpermissive]
  102 |             cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      |                             ~~~~^
      |                                 |
      |                                 double (*)(double) throw () {aka double (*)(double)}
answer.code:102:33: error: cannot bind rvalue ‘(long long int)(y1 + ((sizetype)i))’ to ‘long long int&’
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:102:33: error: invalid conversion from ‘double (*)(double) thr...