QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665392#5549. Game Showkai824#WA 0ms3604kbC++202.2kb2024-10-22 12:08:342024-10-22 12:08:34

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 12:08:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-10-22 12:08:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define eb emplace_back
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
#define F first
#define S second
#define rep(i,a,b) for(int i=a;i<(b);i++)

const int MAXN = 111;

int n, m;
pair <int, string> range[MAXN];
string pre[MAXN];
string suf[MAXN];

bool checkstr(string s) {
  rep(i, 0, m) if (s[i] == '?') return false;
  return true;
}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  cin >> n >> m;
  rep(i, 0, n) {
    int x;
    cin >> x;
    x--;
    string s;
    cin >> s;
    range[i] = {x, s};
  }
  string cur = "";
  rep(i, 0, m) cur += "?";
  int x, y;
  rep(i, 0, n) {
    bool check = false;
    rep(j, range[i].F, range[i].F + range[i].S.size()) {
      if (cur[j] != '?' and range[i].S[j - range[i].F] != cur[j]) check = true;
      else cur[j] = range[i].S[j - range[i].F];
    }
    if (check) break;
    pre[i] = cur;
    x = i;
  }
  cur = "";
  rep(i, 0, m) cur += "?";
  for (int i = n - 1; i >= 0; i--) {
    bool check = false;
    rep(j, range[i].F, range[i].F + range[i].S.size()) {
      if (cur[j] != '?' and range[i].S[j - range[i].F] != cur[j]) check = true;
      else cur[j] = range[i].S[j - range[i].F];
    }
    if (check) break;
    suf[i] = cur;
    y = i;
  }
  if (x + 1 < y) {
    cout << -1;
    return 0;
  }
  if (x >= n - 2 and y <= 1) {
    cout << -2;
    return 0;
  }
  bool check = false;
  string ans;
  if (x >= n - 2 and checkstr(pre[n - 2])) ans = pre[n - 2], check = true;
  if (y <= 1 and checkstr(suf[1])) ans = suf[1], check = true;
  cout << 233;
  rep(i, 1, m - 1) {
    if (x < i - 1 or y > i + 1) continue;
    string tmp;
    bool ok = false;
    rep(j, 0, m) {
      if (pre[i - 1][j] == '?') tmp += suf[i + 1][j];
      else if (suf[i + 1][j] == '?') tmp += pre[i - 1][j];
      else if (pre[i - 1][j] != suf[i + 1][j]) ok = true;
      else tmp += suf[i + 1][j];
    }
    if (ok == false and checkstr(tmp)) {
      if (check) {
        cout << -2;
        return 0;
      }
      check = true;
      ans = tmp;
    }
  }
  cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

input:

4 4
2 3 -4 3
1 2 7 -1
1 3
3 1
1 4
1 1

output:

233

result:

wrong answer 1st lines differ - expected: '5', found: '233'