Submission #1250005

#TimeUsernameProblemLanguageResultExecution timeMemory
1250005fadak-14Triple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
//#include "worldmap.h" #include "triples.h" #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse2") #define ll long long #define db double #define ld long double #define endl '\n' #define eb emplace_back #define em emplace #define pb push_back #define pf push_front #define pp pop_back #define fr first #define sc second #define sz size #define ir insert #define yes cout << "YES" << endl #define no cout << "NO" << endl #define all(x) x.begin() , x.end() #define alice cout << "Alice" << endl #define bob cout << "Bob" << endl #define fo(x , y) for(ll i = x;i < y;i++) using namespace std; mt19937 rd(time(NULL)); //IOI 2025 problems const ll mxn = 1e5+5; const ll md=998244353; //vector<int> g[mxn]; /* "souvenirs" -> 39 points for now void buy_souvenirs(int N, ll P0) { if(N==2){transaction(P0-1) ;return;} if(N==3){ auto x=transaction(P0-1); if(x.fr.sz()==1){ll vl=P0-1-x.sc; transaction(vl-1);transaction(vl-1);} else{ll vl= (P0-1-x.sc) ; vl+=(2-vl%2)%2;vl/=2; transaction(vl-1);} return; } vector<ll>cn(N,0) , vl(N); vl[0]=P0; for(int i =1;i < N;i++) { auto x =transaction(vl[i-1] - 1) ; for(int y: x.fr) cn[y]++; if(x.fr.sz() ==1) vl[i] = vl[i-1] - 1 -x.sc; else vl[i] = vl[i-1] - 2; } for(int i = 1; i<N;i++) { while(cn[i] <i) { transaction(vl[i]); cn[i]++; } } } */ /* "World Map" -> 72 points for now vector<vector<int>> regulate(vector<vector<int>> board) { int n= board.sz(); int m=board[0].sz() ; int k = max(n,m); vector an=vector(k,vector<int> (k)); for(int i=0;i<n;i++)for(int j = 0;j<m ;j++)an[i][j]=board[i][j]; for(int i=0;i<k;i++){for(int j=0;j<k;j++){ if(!an[i][j]){ if(j>0&&an[i][j-1])an[i][j] =an[i][j-1]; else if(i>0&&an[i-1][j]) an[i][j] =an[i-1][j]; else assert(false); } }} return an; } bool vs[mxn] ; vector<pair<int, bool>> st; void dfs(int v, int pa=-1) { vs[v]=true; for(int u:g[v]) { if(vs[u])continue; st.pb({u,true}); dfs(u,v); st.pb({v,false}); } } vector<vector<int>> create_map(int N, int M , vector<int> A , vector<int> B) { for(int i = 1 ; i <= N ;i++) g[i].clear(); fill(vs,vs + N+1, false) ; for(int i = 0 ;i < M;i++){g[A[i]].pb(B[i]) ;g[B[i]].pb(A[i]);} st=vector<pair<int,bool>>{{1,true}}; dfs(1); vector ans=vector(N*3 +(N-1), vector<int> (N*2)) ; int x= 0; for(auto [v,fi]:st) { if(fi) { for(int j=0;j<3;j++){for(int k = 0; k < N*2;k++)ans[x+j][k]=v;} for(int j =0;j <g[v].sz() ;j++)ans[x+1][j*2] = g[v][j]; x+=3; } else{ for(int k =0;k<N*2;k++)ans[x][k]=v; x++; } } return regulate(ans) ; } */ //"Triple Peaks" , goal -> 50 set<tuple<int, int , int>> sn; inline bool works(int i , int j , int k , const vector<int> &H){ int p[3] = {i , j , k}; sort(p , p +3); i = p[0] , j = p[1] , k =p[2]; if(0>i||i >=j || j >=k || k >=H.sz()) return false; if(j-i == H[k] && k - j == H[i]) return false; if(sn.count({i,j,k})) return false; int d[3] = {j - i , k - j , k -i}; int h[3] = {H[i] , H[j] ,H[k]} ; sort(d , d+3); sort(h, h+3); if(d[0]==h[0] && d[1] == h[1] && d[2] == h[2]) {sn.em(i , j , k); return true;} return false; } struct comb{ map<int, int> a; ll operator*(const comb& b)const{ if(a.sz() > d.a.sz()) return b * *this; ll o=0; for(auto [i,v] :a) if(b.a.count(a)) o+=(ll)v*b.a.at(i); return o; } void insert(int v){a[v]++;} void remove(int v) {if(!--a[v]){a.erase(v);}} }; ll count_triples(vector<int> H) { cerr << "count_triples(...)\n"; const int N = H.sz(); ll ct=0; vector<int> xm(N) , xp(N); for(int x = 0 ; x< N ; x++) {xm[x]=x-H[x]; xp[x] =x+H[x];} map<int, comb>lf, rt; for(int i =0 ; i < N;i++)rt[xp[i]].insert(xm[i]); for(int j = 0 ; j < N;j++){ rt[xp[j]].remove(xm[j]); ct += lf[xm[j]] * rt[xp[j]]; lf[xm[j]].insert(xp[j]); } cerr<<"pre-trivial: "<< ct<< endl; for(int i =0 ; i <N;i++){ for(int j :{i + H[i], i-H[i]}){ if(j < 0||j>=N)continue; for(int k :{i+H[j], i-H[j], j+H[j],j-H[j]}) ct+=works(i , j , k , H); } } cerr<< " = "<<ct<<endl; return ct; } vector<int> construct_range(int M , int K) { return {}; }

Compilation message (stderr)

triples.cpp: In member function 'long long int comb::operator*(const comb&) const':
triples.cpp:124:21: error: 'd' was not declared in this scope; did you mean 'rd'?
  124 |         if(a.sz() > d.a.sz()) return b * *this;
      |                     ^
      |                     rd
triples.cpp:126:40: error: no matching function for call to 'std::map<int, int>::count(const std::map<int, int>&) const'
  126 |         for(auto [i,v] :a) if(b.a.count(a)) o+=(ll)v*b.a.at(i);
      |                               ~~~~~~~~~^~~
In file included from /usr/include/c++/11/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from triples.cpp:3:
/usr/include/c++/11/bits/stl_map.h:1221:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
 1221 |         count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
      |         ^~~~~
/usr/include/c++/11/bits/stl_map.h:1221:9: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<int, int>*)this)->std::map<int, int>::_M_t.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<int, int>::count<_Kt>(const _Kt&) const [with _Kt = std::map<int, int>]':
triples.cpp:126:40:   required from here
/usr/include/c++/11/bits/stl_map.h:1221:65: error: no matching function for call to 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::_M_count_tr(const std::map<int, int>&) const'
 1221 |         count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
      |                                                 ~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/11/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from triples.cpp:3:
/usr/include/c++/11/bits/stl_tree.h:1314:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Kt = _Kt; _Req = _Req; _Key = int; _Val = std::pair<const int, int>; _KeyOfValue = std::_Select1st<std::pair<const int, int> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
 1314 |         _M_count_tr(const _Kt& __k) const
      |         ^~~~~~~~~~~
/usr/include/c++/11/bits/stl_tree.h:1314:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/11/string:48,
                 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 triples.cpp:3:
/usr/include/c++/11/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using __has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<int>; _SfinaeType = std::map<int, int>]':
/usr/include/c++/11/bits/stl_tree.h:1312:9:   required by substitution of 'template<class _Kt> decltype (((const std::map<int, int>*)this)->std::map<int, int>::_M_t.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<int, int>::count<_Kt>(const _Kt&) const [with _Kt = std::map<int, int>]'
triples.cpp:126:40:   required from here
/usr/include/c++/11/bits/stl_function.h:1413:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<int>, std::map<int, int>, void>'
 1413 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from triples.cpp:3:
/usr/include/c++/11/bits/stl_map.h:1215:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::size_type = long unsigned int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]'
 1215 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/11/bits/stl_map.h:1215:29: note:   no known conversion for argument 1 from 'const std::map<int, int>' to 'const key_type&' {aka 'const int&'}
 1215 |       count(const key_type& __x) const
      |             ~~~~~~~~~~~~~~~~^~~