Submission #44159

#TimeUsernameProblemLanguageResultExecution timeMemory
44159ShadowLightZagonetka (COI18_zagonetka)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define TASKNAME "" using namespace std; const int INF = 1e9 + 7; const int MAXN = 1e6 + 7; const double EPS = 1e-8; #ifdef MY #define cout ssout #define cin ssin #endif vector <vector <int> > gr; vector <vector <int> > rev_gr; int n; vector <int> p; vector <int> pos; stringstream ssout, ssin; vector <pair <int, int> > edges; void inter() { string s; ssout >> s; vector <int> q(n); for (int i = 0; i < n; i++) { ssout >> q[i]; printf("%d ", q[i]); } printf("\n"); for (auto p : edges) { printf("%d %d\n", q[p.first], q[p.second]); if (q[p.first] > q[p.second]) { cin << 0; cerr << "Inter3 0\n"; return; } } cin << 1; cerr << "Inter3 1\n"; } void query(vector <int> &a) { cout << "query "; for (int x : a) { cout << x + 1 << " "; } cout << endl; } vector <bool> used; void dfs(int v) { if (used[v]) return; used[v] = 1; for (int u : rev_gr[v]) { dfs(u); } } vector <int> lvls; vector <bool> used1; int main() { #ifdef MY //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #else //freopen(TASKNAME".in", "r", stdin); //freopen(TASKNAME".out", "w", stdout); #endif // MY scanf("%d", &n); p.resize(n); pos.resize(n, 0); for (int i = 0; i < n; i++) { scanf("%d", &p[i]); p[i]--; pos[p[i]] = i; } int m; scanf("%d", &m); for (int i = 0; i < m; i++) { int v, u; scanf("%d%d", &v, &u); v--, u--; edges.push_back({v, u}); } gr.resize(n); rev_gr.resize(n); int iter = 0; for (int i = n - 1; i >= 0; i--) { used.assign(n, 0); for (int j = i + 1; j < n; j++) { if (used[j]) { gr[j].push_back(i); rev_gr[i].push_back(j); iter++; continue; } auto q = p; int v = j; while (gr[v].size()) { int u = gr[v][0]; swap(q[pos[v]], q[pos[u]]); v = u; } swap(q[pos[v]], q[pos[i]]); v = i; while (rev_gr[v].size()) { int u = rev_gr[v].back(); if (u > j) break; swap(q[pos[v]], q[pos[u]]); v = u; } query(q); inter(); int ans; //cerr << "Inter " << cin.str() << endl; cin >> ans; cin.clear(); //cerr << "Inter2 " << ans << endl; if (!ans) { gr[j].push_back(i); rev_gr[i].push_back(j); printf("%d %d\n", i, j); dfs(j); iter++; } } } cout << "end" << endl; vector <int> resa(n), resb(n); set <int> q; vector <int> cnt(n, 0); for (int i = 0; i < n; i++) { cnt[i] = gr[i].size(); if (!cnt[i]) { q.insert(pos[i]); } } int now = 0; while (!q.empty()) { int v = *q.begin(); q.erase(v); resa[v] = now++; for (int u : rev_gr[p[v]]) { cnt[u]--; if (!cnt[u]) { q.insert(pos[u]); } } } for (int i = 0; i < n; i++) { cnt[i] = gr[i].size(); if (!cnt[i]) { q.insert(pos[i]); } } now = 0; while (!q.empty()) { int v = *q.rbegin(); q.erase(v); resb[v] = now++; for (int u : rev_gr[p[v]]) { cnt[u]--; if (!cnt[u]) { q.insert(pos[u]); } } } for (int x : resa) { printf("%d ", x + 1); } printf("\n"); cout << endl; for (int x : resb) { printf("%d ", x + 1); } printf("\n"); cout << endl; }

Compilation message (stderr)

zagonetka.cpp: In function 'void inter()':
zagonetka.cpp:40:17: error: no match for 'operator<<' (operand types are 'std::istream {aka std::basic_istream<char>}' and 'int')
             cin << 0;
             ~~~~^~~~
zagonetka.cpp:40:17: note: candidate: operator<<(int, int) <built-in>
zagonetka.cpp:40:17: note:   no known conversion for argument 1 from 'std::istream {aka std::basic_istream<char>}' to 'int'
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/regex.h:1483:5: note: candidate: template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::__cxx11::sub_match<_Bi_iter>&)
     operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1483:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:3160:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::piecewise_linear_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:3160:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2944:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::piecewise_constant_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2944:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2734:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::discrete_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2734:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2275:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::student_t_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2275:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2200:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::fisher_f_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2200:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2036:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::chi_squared_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2036:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:1963:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::lognormal_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1963:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:1667:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::binomial_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1667:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:1400:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::poisson_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1400:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:1195:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::negative_binomial_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1195:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:831:5: note: candidate: template<class _RandomNumberEngine, long unsigned int __k, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::shuffle_order_engine<_RandomNumberEngine, __k>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:831:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:702:5: note: candidate: template<class _RandomNumberEngine, long unsigned int __p, long unsigned int __r, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::discard_block_engine<_RandomNumberEngine, __p, __r>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:702:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:632:5: note: candidate: template<class _UIntType, long unsigned int __w, long unsigned int __s, long unsigned int __r, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::subtract_with_carry_engine<_UIntType, __w, __s, __r>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:632:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:156:5: note: candidate: template<class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::linear_congruential_engine<_UIntType, __a, __c, __m>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:156:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2598:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::extreme_value_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2598:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2522:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::weibull_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2522:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:1731:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::exponential_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1731:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2444:5: note: candidate: template<class _RealType1, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::gamma_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2444:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:1080:5: note: candidate: template<class _IntType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::geometric_distribution<_IntType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1080:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:1898:5: note: candidate: template<class _RealType1, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::normal_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:1898:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:998:5: note: candidate: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::bernoulli_distribution&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:998:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:2123:5: note: candidate: template<class _RealType, class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::cauchy_distribution<_RealType>&)
     operator<<(std::basic_ostream<_CharT, _Traits>& __os,
     ^~~~~~~~
/usr/include/c++/7/bits/random.tcc:2123:5: note:   template argument deduction/substitution failed:
zagonetka.cpp:40:20: note:   'std::istream {aka std::basic_istream<char>}' is not derived from 'std::basic_ostream<_CharT, _Traits>'
             cin << 0;
                    ^
In file included from /usr/include/c++/7/random:51:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:108,
                 from zagonetka.cpp:1:
/usr/include/c++/7/bits/random.tcc:936:5: note: candidate: template<class _