Submission #1143324

#TimeUsernameProblemLanguageResultExecution timeMemory
1143324elisaipateWalk (POI13_spa)C++20
Compilation error
0 ms0 KiB
#include <iostream>

using namespace std;

const int nmax = 1e7;
bool viz[nmax];
int n;

int tr( string s ) {
  int p2 = 1, rez = 0;
  for( int i = n - 1; i >= 0; i-- ) {
    rez = rez + p2 * (s[i] - '0');
    p2 *= 2;
  }
  return rez;
}

void bfs( int vf ) {
  viz[vf] = true;
  int p2 = 1;
  for( int i = 0; i < n; i++ ) {
    if( (vf / p2) % 2 == 0 ) {
      if( viz[vf + p2] == false )
        bfs( vf + p2 );
    } else {
      if( viz[vf - p2] == false )
        bfs( vf - p2 );
    }
    p2 *= 2;
  }
}

signed main()
{
    int k, a;
    cin >> n >> k;
    int x, y;
    string s;
    cin >> s;
    x = tr(s);
    cin >> s;
    y = tr(s);
    if( x == y ) {
      cout << "TAK"";
      return 0;
    }
    for( int i = 0; i < k; i++ ) {
      cin >> s;
      a = tr(s);
      viz[a] = true;
      //cout << v[i] << " ";
    }
    //cout << "\n";
    bfs( x );
    if( viz[y] == true )
      cout << "TAK";
    else
      cout << "NIE";

    return 0;
}

Compilation message (stderr)

spa.cpp:44:20: warning: missing terminating " character
   44 |       cout << "TAK"";
      |                    ^
spa.cpp:44:20: error: missing terminating " character
   44 |       cout << "TAK"";
      |                    ^~
spa.cpp: In function 'int main()':
spa.cpp:44:20: error: expected ';' before 'return'
   44 |       cout << "TAK"";
      |                    ^
      |                    ;
   45 |       return 0;
      |       ~~~~~~