Submission #525082


Source Code Expand

/*
 * b.cc: B: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200;
const int MAX_L = 100000;

/* typedef */

typedef bitset<MAX_N> bs;

/* global variables */

bs as[26][MAX_L];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;

  bs gl;
  int maxl = 0;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;

    int l = s.size();
    for (int j = 0; j < l; j++) as[s[j] - 'a'][j].set(i);

    if (maxl < l) maxl = l;

    gl.set(i);
  }

  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < maxl; j++) {
      int k = j;
      bs b;
      while (k < maxl && as[i][k].any()) b |= as[i][k++];
      if (k - j >= n && b == gl) {
	puts("YES");
	return 0;
      }
      j = k;
    }
  }
  
  puts("NO");
  return 0;
}

Submission Info

Submission Time
Task B - コメント
User tnakao
Language C++ (G++ 4.6.4)
Score 0
Code Size 1142 Byte
Status CE

Compile Error

./Main.cpp:33:9: error: ‘bitset’ does not name a type
./Main.cpp:37:1: error: ‘bs’ does not name a type
./Main.cpp: In function ‘int main()’:
./Main.cpp:47:3: error: ‘bs’ was not declared in this scope
./Main.cpp:47:6: error: expected ‘;’ before ‘gl’
./Main.cpp:55:33: error: ‘as’ was not declared in this scope
./Main.cpp:59:5: error: ‘gl’ was not declared in this scope
./Main.cpp:65:10: error: expected ‘;’ before ‘b’
./Main.cpp:66:26: error: ‘as’ was not declared in this scope
./Main.cpp:66:42: error: ‘b’ was not declared in this scope
./Main.cpp:67:25: error: ‘b’ was not declared in this scope
./Main.cpp:67:30: error: ‘gl’ was not declared in this scope