Submission #133387

#TimeUsernameProblemLanguageResultExecution timeMemory
133387ZexJetpack (COCI16_jetpack)C++11
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define LL long long #define INF INT_MAX #define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl; struct el{ int s; int dur; el(){} el( int _s, int _d ){ s = _s; dur = _d; } }; const int maxN = 10; const int maxM = 100000; const int N = 10; int M; bool vis[maxN][maxM]; bool bt[maxN][maxM]; // 1 - HOLD 0 - LET GO int prev[maxN][maxM]; char mat[maxN][maxM]; bool dir( int a, int b ){ if( a == b ){ return a == N-1; } return b < a; } void f( int H, int n, int PRH ){ if( vis[H][n] || mat[H][n] == 'X' ) return; vis[H][n] = true; bt[H][n] = dir( H, PRH ); prev[H][n] = PRH; // cout << H << " " << n << " " << PRH << endl; if( n == M-1 ) return; if( H == N-1 ){ f( H, n+1, H ); f( H-1, n+1, H ); }else if( H == 0 ){ f( H+1, n+1, H ); f( H, n+1, H ); }else{ f( H+1, n+1, H ); f( H-1, n+1, H ); } } void findPath( int H ){ int n = M-1; int dur = 0; bool b; vector <el> res; vector <int> debug; do{ // cout << H << " " << n << endl; b = bt[H][n]; debug.push_back(b); if( b ) { dur++; } else{ if( dur ) res.push_back( el( n, dur ) ); dur = 0; } H = prev[H][n]; n--; }while( n >= 0 ); cout << res.size() << endl; for(int i=res.size()-1;i>=0;i--){ cout << res[i].s << " " << res[i].dur << endl; } // reverse( debug.begin(), debug.end() ); // for(int i=0;i<debug.size();i++) cout << debug[i] << " "; cout << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); memset( vis, 0, sizeof vis ); memset( prev, -1, sizeof prev ); cin >> M; for(int i=N-1;i>=0;i--) for(int j=0;j<M;j++) cin >> mat[i][j]; f( 0, 0, N ); for(int i=0;i<N;i++){ if( vis[i][M-1] ){ findPath( i ); break; } } }

Compilation message (stderr)

jetpack.cpp: In function 'void f(int, int, int)':
jetpack.cpp:36:5: error: reference to 'prev' is ambiguous
     prev[H][n] = PRH;
     ^~~~
jetpack.cpp:19:5: note: candidates are: int prev [10][100000]
 int prev[maxN][maxM];
     ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 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 jetpack.cpp:1:
/usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note:                 template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)
     prev(_BidirectionalIterator __x, typename
     ^~~~
jetpack.cpp: In function 'void findPath(int)':
jetpack.cpp:73:13: error: reference to 'prev' is ambiguous
         H = prev[H][n];
             ^~~~
jetpack.cpp:19:5: note: candidates are: int prev [10][100000]
 int prev[maxN][maxM];
     ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 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 jetpack.cpp:1:
/usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note:                 template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)
     prev(_BidirectionalIterator __x, typename
     ^~~~
jetpack.cpp: In function 'int main()':
jetpack.cpp:91:13: error: reference to 'prev' is ambiguous
     memset( prev, -1, sizeof prev );
             ^~~~
jetpack.cpp:19:5: note: candidates are: int prev [10][100000]
 int prev[maxN][maxM];
     ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 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 jetpack.cpp:1:
/usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note:                 template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)
     prev(_BidirectionalIterator __x, typename
     ^~~~
jetpack.cpp:91:30: error: reference to 'prev' is ambiguous
     memset( prev, -1, sizeof prev );
                              ^~~~
jetpack.cpp:19:5: note: candidates are: int prev [10][100000]
 int prev[maxN][maxM];
     ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 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 jetpack.cpp:1:
/usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note:                 template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)
     prev(_BidirectionalIterator __x, typename
     ^~~~