QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89320#5251. ConstellationsMilk_FengCompile Error//C++2.2kb2023-03-19 19:26:072023-03-19 19:26:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-19 19:26:10]
  • 评测
  • [2023-03-19 19:26:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
//typedef __int128 LLL;

int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9') c == '-' ? f = -1: 0, c = getchar();
	while(c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
    return x * f;
}

LL X[2050], Y[2050];
double dis[4050][4050];
LL dis_[4050][4050];
LL size[4050];

struct Pair {
    int i, j;
    Pair(int _i, int _j): i(_i), j(_j) {}
    bool operator < (const Pair &o) const {
        
        int thisnew = min(i, j), thisold = max(i, j);
        int othernew = min(o.i, o.j), otherold = max(o.i, o.j);
        
        if(dis[i][j] == dis[o.i][o.j])
            return thisold == otherold ? thisnew > othernew : thisold > otherold;
        else return dis[i][j] < dis[o.i][o.j];
    }
};

set<Pair> s[4050];
set<int> exist;

signed main() {
    int n = read();
    for(int i = 1; i <= n; ++i) X[n - i + 1] = read(), Y[n - i + 1] = read();
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            if(i == j) continue;
            dis[i][j] = dis_[i][j] = (X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]);
            s[i].insert(Pair(i, j));
        }
        exist.insert(i);
        size[i] = 1;
    }
    
    while(exist.size() > 1) {
        Pair mn = *s[*exist.begin()].begin();
        
        for(int i: exist) {
            Pair pair = *(s[i].begin());
            if(pair < mn) mn = pair;
        }
        int id1 = mn.i, id2 = mn.j;
        
        size[++n] = size[id1] + size[id2];        
        for(int i: exist) {
            if(i == id1 || i == id2) continue;
            dis_[i][n] = dis_[n][i] = dis_[i][id1] + dis_[i][id2];
            dis[i][n] = dis[n][i] = 1.0 * dis_[i][n] / size[i] / size[n];
        }
        
        for(int i: exist) {
            if(i != id1) s[i].erase(Pair(i, id1));
            if(i != id2) s[i].erase(Pair(i, id2));
            if(i != id1 && i != id2) s[i].insert(Pair(i, n)), s[n].insert(Pair(n, i));
        }
        
        exist.erase(id1), exist.erase(id2);
        exist.insert(n);
        
        printf("%d\n", size[n]);
    }
    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:47:9: error: reference to ‘size’ is ambiguous
   47 |         size[i] = 1;
      |         ^~~~
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/range_access.h:254:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:245:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:18:4: note:                 ‘LL size [4050]’
   18 | LL size[4050];
      |    ^~~~
answer.code:59:9: error: reference to ‘size’ is ambiguous
   59 |         size[++n] = size[id1] + size[id2];
      |         ^~~~
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/range_access.h:254:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:245:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:18:4: note:                 ‘LL size [4050]’
   18 | LL size[4050];
      |    ^~~~
answer.code:59:21: error: reference to ‘size’ is ambiguous
   59 |         size[++n] = size[id1] + size[id2];
      |                     ^~~~
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/range_access.h:254:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:245:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
answer.code:18:4: note:                 ‘LL size [4050]’
   18 | LL size[4050];
      |    ^~~~
answer.code:59:33: error: reference to ‘size’ is ambiguous
   59 |         size[++n] = size[id1] + size[id2];
      |                                 ^~~~
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/range_access.h:254:5: note: candidates are: ‘template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])’
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/11/bits/range_access.h:245:5: note:                 ‘template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)’
  245 |     size(const _Container& ...