QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#872124#8618. Have You Seen This Subarray?ucup-team139#Compile Error//C++233.1kb2025-01-25 23:41:472025-01-25 23:41:54

Judging History

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

  • [2025-01-25 23:41:54]
  • 评测
  • [2025-01-25 23:41:47]
  • 提交

answer

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <climits>
#include <iomanip>
using namespace std;

#define int int64_t
using namespace std;
int base = 100003;

vector<int> lar(vector<int> &v, int i, int s)
{
  vector<int> res;
  for (int j = max(int(0), i - s + 1); j <= min(i, (int)v.size() - s); ++j)
  {
    int ans = 0;
    bool inc = 1;
    for (int k = j; k < j + s; ++k)
      ans = ans * base + v[k];
    for (int k = j + 1; k < j + s; ++k)
      if (v[k] - v[k - 1] != 1)
        inc = 0;
    if (!inc)
      res.push_back(ans);
  }
  return res;
}
vector<int> larii(vector<int> &v, int i1, int i2, int s)
{
  vector<int> r1 = lar(v, i1, s);
  vector<int> r2 = lar(v, i2, s);
  for (int i = 0; i < (int)r2.size(); ++i)
    r1.push_back(r2[i]);
  return r1;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, _m, q;
  cin >> n >> _m >> q;

  if (n <= 100)
  {
    const int MAXM = 100'001;
    vector ds(n + 1, vector(n + 1, bitset<MAXM>()));

    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
      a[i] = i;

    auto upd = [&](int t)
    {
      for (int i = 1; i + 1 <= n; i++)
      {
        ds[a[i]][a[i + 1]][t] = true;
      }
    };

    upd(0);
    for (int i = 1; i <= _m; i++)
    {
      int x, y;
      cin >> x >> y;
      swap(a[x], a[y]);
      upd(i);
    }

    for (int i = 0; i < q; i++)
    {
      int k;
      cin >> k;
      vector<int> b(k);
      for (auto &j : b)
        cin >> j;

      bitset<MAXM> ans;
      ans = ~ans;
      for (int j = 0; j + 1 < k; j++)
      {
        ans &= ds[b[j]][b[j + 1]];
      }
      cout << ans._Find_first() << "\n";
    }

    return;
  }

  vector<int> v(n);
  for (int i = 0; i < n; ++i)
    v[i] = i + 1;
  array<map<int, int>, 5> m;
  for (int i = 1; i <= _m; ++i)
  {
    int i1, i2;
    cin >> i1 >> i2;
    --i1;
    --i2;
    swap(v[i1], v[i2]);
    for (int s = 0; s < 5; ++s)
      for (auto x : larii(v, i1, i2, s + 1))
        if (!m[s].count(x))
          m[s][x] = i;
  }
  for (int _ = 0; _ < q; ++_)
  {
    int bl;
    cin >> bl;
    vector<int> b(bl);
    for (auto &o : b)
      cin >> o;
    int ans = 0;
    for (int i = 0; i < bl; ++i)
    {
      for (int s = 0; s < 5; ++s)
        if (i + s < bl)
        {
          int as = 0;
          for (int j = i; j <= i + s; ++j)
            as = as * base + b[j];
          if (m[s].count(as))
            ans = max(ans, m[s][as]);
        }
    }
    cout << ans << '\n';
  }
  return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:117:5: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
  117 |     return;
      |     ^~~~~~