Submission #531548

#TimeUsernameProblemLanguageResultExecution timeMemory
531548christinelynn사육제 (CEOI14_carnival)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int a[151], n; map<pair<int,int>, int> mp; int ask(int x, int y){ if(x > y) swap(x, y); if(mp.find({x, y})) { return mp[{x, y}]; } cout << "2 " << x << " " << y << endl; int z; cin >> z; mp[{x, y}] = z; return z; } int main(){ cin.tie(0) -> ios_base::sync_with_stdio(0); cin >> n; iota(a, a + n, 1); for(int i=0;i<n;i++) { for(int j=0;j<i;j++) { if(ask(a[i], a[j]) == 1) { a[i] = a[j]; } } } cout << "0 "; for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl; }

Compilation message (stderr)

carnival.cpp: In function 'int ask(int, int)':
carnival.cpp:9:13: error: could not convert 'mp.std::map<std::pair<int, int>, int>::find(std::pair<int, int>(x, y))' from 'std::map<std::pair<int, int>, int>::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::iterator'} to 'bool'
    9 |   if(mp.find({x, y}))
      |      ~~~~~~~^~~~~~~~
      |             |
      |             std::map<std::pair<int, int>, int>::iterator {aka std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::iterator}
carnival.cpp: In function 'int main()':
carnival.cpp:36:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   36 |   for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
      |   ^~~
carnival.cpp:36:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   36 |   for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
      |                                             ^~~~