Submission #72493

#TimeUsernameProblemLanguageResultExecution timeMemory
72493 (#118)Key of Impassable Doors (FXCUP3_key)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include"key.h" using namespace std; int sz[1005], left[1005]; int out[1005], mb[1005]; vector<int> cycle[1005]; void EnsureKeyInfo(int N){ for(int i=1;i<=N;i++) { TakeKey(i); sz[i] = Explore(); if(sz[i] == 1) out[i] = i; else left[sz[i]]++; } for(int i=1;i<=N;i++) { if(mb[i] || out[i]) continue; vector<int> cand; for(int j=1;j<=N;j++) { if(sz[j] == sz[i]-1) cand.push_back(j); } random_shuffle(cand.begin(), cand.end()); for(int j : cand) { TakeKey(i); TakeKey(j); int ret = Explore(); if(ret == sz[i]) { out[i] = j; break; } } if(out[i]) { left[sz[i]]--; continue; } if(left[sz[i]] < sz[i]) continue; cand.clear(); for(int j=i+1;j<=N;j++) { if(i == j) continue; if(sz[i] == sz[j] && !mb[j]) cand.push_back(j); } if(cand.size() == sz[i]-1) { cand.push_back(i); sort(cand.begin(), cand.end()); int x = cand[0]; for(int j : cand) { cycle[x].push_back(j); mb[j] = x; } continue; } else { vector<int> rcand; random_shuffle(cand.begin(), cand.end()); for(int j : cand) { TakeKey(i); TakeKey(j); int ret = Explore(); if(ret == sz[i]) rcand.push_back(j); if(rcand.size() == sz[i]-1) break; } rcand.push_back(i); sort(rcand.begin(), rcand.end()); int x = rcand[0]; for(int j : rcand) { cycle[x].push_back(j); mb[j] = x; } } } for(int i=1;i<=N;i++) { if(mb[i]) { if(cycle[i].empty()) continue; for(int x : cycle[i]) { for(int y : cycle[i]) { Report(x,y); } } } else { int prv = i; Report(i,i); int x = out[i]; while(x != prv) { if(mb[x]) { for(int j : cycle[mb[x]]) { Report(i, j); } break; } else { Report(i, x); prv = x; x = out[x]; } } } } }

Compilation message (stderr)

key.cpp: In function 'void EnsureKeyInfo(int)':
key.cpp:14:10: error: reference to 'left' is ambiguous
     else left[sz[i]]++;
          ^~~~
key.cpp:5:15: note: candidates are: int left [1005]
 int sz[1005], left[1005];
               ^~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from key.cpp:1:
/usr/include/c++/7/bits/ios_base.h:999:3: note:                 std::ios_base& std::left(std::ios_base&)
   left(ios_base& __base)
   ^~~~
key.cpp:33:7: error: reference to 'left' is ambiguous
       left[sz[i]]--;
       ^~~~
key.cpp:5:15: note: candidates are: int left [1005]
 int sz[1005], left[1005];
               ^~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from key.cpp:1:
/usr/include/c++/7/bits/ios_base.h:999:3: note:                 std::ios_base& std::left(std::ios_base&)
   left(ios_base& __base)
   ^~~~
key.cpp:36:8: error: reference to 'left' is ambiguous
     if(left[sz[i]] < sz[i]) continue;
        ^~~~
key.cpp:5:15: note: candidates are: int left [1005]
 int sz[1005], left[1005];
               ^~~~
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from key.cpp:1:
/usr/include/c++/7/bits/ios_base.h:999:3: note:                 std::ios_base& std::left(std::ios_base&)
   left(ios_base& __base)
   ^~~~
key.cpp:42:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(cand.size() == sz[i]-1) {
        ~~~~~~~~~~~~^~~~~~~~~~
key.cpp:59:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(rcand.size() == sz[i]-1) break;
            ~~~~~~~~~~~~~^~~~~~~~~~