fork(1) download
  1. #include<bits/stdc++.h>
  2. #define mod 1000000007
  3. #define ll long long
  4. using namespace std;
  5. int dem=0,n;
  6. char a[101][101];
  7. string s[1000];
  8. string convert(string temp){
  9. string res="";
  10. int n=temp.length();
  11. if(n%3) temp.insert(0,3-n%3,'0');
  12. for(int i=0;i<n;i+=3){
  13. int t=0;
  14. for(int j=0;j<3;j++){
  15. t+=(temp[j+i]-'0')*pow(2,2-j);
  16. }
  17. t=(int) t;
  18. res+=(char)('0'+t);
  19. }
  20. return res;
  21. }
  22. void move(int x,int y,string temp){
  23. if(x==n-1&&y==n-1){
  24. temp=temp+(char)(a[x][y]);
  25. s[dem]=temp;
  26. dem++;
  27. }
  28. else if(x<n&&y<n){
  29. if((a[x][y+1]=='0')||(a[x+1][y]=='0')){
  30. if(a[x][y+1]=='0'){
  31. move(x,y+1,temp+(char)a[x][y]);
  32. }
  33. else move(x+1,y,temp+(char)a[x][y]);
  34. }
  35. else{
  36. move(x,y+1,temp+(char)a[x][y]);
  37. move(x+1,y,temp+(char)a[x][y]);
  38. }
  39. }
  40. }
  41. int main(){
  42. ios_base::sync_with_stdio(false);
  43. cin>>n;
  44. for(int i=0;i<n;i++){
  45. for(int j=0;j<n;j++) cin>>a[i][j];
  46. }
  47. move(0,0,"");
  48. // sort(s,s+dem);
  49. cout<<convert(*min_element(s,s+dem));
  50. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5


  
1
  0 1 1 0


  
0
  0 1 0 1


  
0
  0 1 0 1


  
1
  0 0 1 1


  
1
  1 0 1 0

compilation info
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/istream:38,
                 from /usr/include/c++/6/sstream:38,
                 from /usr/include/c++/6/complex:45,
                 from /usr/include/c++/6/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:52,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h: In instantiation of ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = int; _OI = const char*]’:
/usr/include/c++/6/bits/stl_algobase.h:422:45:   required from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = int; _OI = const char*]’
/usr/include/c++/6/bits/stl_algobase.h:487:39:   required from ‘_OI std::move(_II, _II, _OI) [with _II = int; _OI = const char*]’
prog.cpp:47:13:   required from here
/usr/include/c++/6/bits/stl_algobase.h:377:57: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
       typedef typename iterator_traits<_II>::value_type _ValueTypeI;
                                                         ^~~~~~~~~~~
/usr/include/c++/6/bits/stl_algobase.h:379:64: error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<int>’
       typedef typename iterator_traits<_II>::iterator_category _Category;
                                                                ^~~~~~~~~
/usr/include/c++/6/bits/stl_algobase.h:383:9: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
       const bool __simple = (__is_trivial(_ValueTypeI)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~
                       && __is_pointer<_II>::__value
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       && __is_pointer<_OI>::__value
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         && __are_same<_ValueTypeI, _ValueTypeO>::__value);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_algobase.h:386:44: error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<int>’
       return std::__copy_move<_IsMove, __simple,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        _Category>::__copy_m(__first, __last, __result);
                        ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
stdout
Standard output is empty