| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 955398 | Duine | Matching (CEOI11_mat) | C++14 | 2054 ms | 29264 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, m, h[1000005]{}, tmp[1000005]{}, g[1000005]{}, posh[1000005]{}, posg[1000005]{};
int find_pos (int x)
{
int l = 1, r = n, mid;
while (l <= r)
{
mid = l + ((r-l) >> 1);
if (x == tmp[mid]) return mid;
else if (x > tmp[mid]) l = mid+1;
else r = mid-1;
}
}
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i)
{
cin >> h[i];
tmp[i] = h[i];
}
for (int i = 1; i <= m; ++i)
cin >> g[i];
sort (tmp+1, tmp+n+1);
for (int i = 1; i <= n; ++i)
posh[i] = find_pos(h[i]);
for (int i = 1; i <= n; ++i)
tmp[i] = g[i];
sort (tmp+1, tmp+n+1);
for (int i = 1; i <= n; ++i)
posg[i] = find_pos(g[i]);
vector <int> res;
for (int i = 1; i <= m-n+1; ++i)
{
bool check = true;
for (int j = 1; j <= n; ++j)
if (posg[i+j-1] != posh[j]) { check = false; break; }
if (check) res.push_back(i);
for (int j = 1; j < n; ++j)
if (g[i] < g[i+j]) --posg[i+j];
int mn = n;
for (int j = 1; j < n; ++j)
if (g[i+n] < g[i+j]) { mn = min (mn, posg[i+j]); ++posg[i+j]; }
posg[i+n] = mn;
}
cout << res.size() << '\n';
for (int i = 0; i < res.size(); ++i)
cout << res[i] << ' ';
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
