Submission #6496893
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T) vector<vector<T>>
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x, c) for (auto x : (c))
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) stable_sort(ALL(c))
#define RSORT(c) stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define $(x) {cout << #x << " = " << (x) << endl;}
#define SSORT(c) stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
void solve(LL N, LL K, vector<LL> A){
VVI results; // of 1st, 2nd, ..., until returns to an empty set
VI B(A);
REP(k, K) {
/*cout << "B\n";
REP(i, SZ(B)) {
cout << B[i] << " ";
}
cout << endl;*/
VB masked(SZ(B));
unordered_map<LL, LL> c; // number, position + 1
REP(i, SZ(B)) {
//$(i);
if (c.count(B[i]) == 0) {
c[B[i]] = i + 1;
} else {
FOR(j, c[B[i]] - 1, i + 1) {
masked[j] = true;
}
unordered_map<LL, LL> d;
REP(j, c[B[i]] - 1) {
if (!masked[j]) {
d[B[j]] = j + 1;
}
}
c = d;
}
/*cout << "c\n";
EACH(cc, c) {
cout << cc.first << ":" << cc.second << " ";
}
cout << endl;*/
}
VP x;
EACH(cc, c) {
x.PB(cc);
//$(cc.first);
}
SSORT(x);
VI result;
//$(k);
//cout << "result\n";
REP(i, SZ(x)) {
//cout << "hoge\n";
result.PB(x[i].first);
//cout << result[i] << " ";
}
/*cout << "c\n";
cout << endl;
$(SZ(c));*/
if (SZ(c) == 0) { // period == k + 1
/*cout << "d\n";
cout << "0!\n";*/
if (k == 0) {
return;
}
VI r(results[K % (k + 1) - 1]);
REP(i, SZ(r)) {
cout << r[i] << " ";
}
cout << endl;
return;
//cout << "0!" << endl;
}
//cout << "1\n";
results.PB(result);
//cout << "2\n";
REP(i, SZ(A)) {
result.PB(A[i]);
}
B = result;
}
VI r(results[SZ(results) - 1]);
REP(i, SZ(r)) {
cout << r[i] << " ";
}
cout << endl;
}
int main(){
LL N;
scanf("%lld",&N);
LL K;
scanf("%lld",&K);
vector<LL> A(N-1-0+1);
for(int i = 0 ; i < N-1-0+1 ; i++){
scanf("%lld",&A[i]);
}
solve(N, K, move(A));
return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - Do Not Duplicate |
| User |
yetnone |
| Language |
C++14 (GCC 5.4.1) |
| Score |
0 |
| Code Size |
3191 Byte |
| Status |
TLE |
| Exec Time |
2108 ms |
| Memory |
69044 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:106:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&N);
^
./Main.cpp:108:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&K);
^
./Main.cpp:111:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&A[i]);
^
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
0 / 700 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
| All |
01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 01-01.txt |
AC |
1 ms |
256 KiB |
| 01-02.txt |
TLE |
2103 ms |
1884 KiB |
| 01-03.txt |
TLE |
2103 ms |
2044 KiB |
| 01-04.txt |
TLE |
2103 ms |
2944 KiB |
| 01-05.txt |
TLE |
2103 ms |
1824 KiB |
| 01-06.txt |
TLE |
2103 ms |
3072 KiB |
| 01-07.txt |
TLE |
2103 ms |
5112 KiB |
| 01-08.txt |
TLE |
2103 ms |
3824 KiB |
| 01-09.txt |
TLE |
2104 ms |
6284 KiB |
| 01-10.txt |
TLE |
2104 ms |
6620 KiB |
| 01-11.txt |
TLE |
2108 ms |
62776 KiB |
| 01-12.txt |
TLE |
2107 ms |
58916 KiB |
| 01-13.txt |
TLE |
2108 ms |
64636 KiB |
| 01-14.txt |
TLE |
2103 ms |
1920 KiB |
| 01-15.txt |
TLE |
2103 ms |
3072 KiB |
| 01-16.txt |
TLE |
2104 ms |
3456 KiB |
| 01-17.txt |
TLE |
2103 ms |
3456 KiB |
| 01-18.txt |
TLE |
2103 ms |
3456 KiB |
| 01-19.txt |
TLE |
2103 ms |
3456 KiB |
| 01-20.txt |
TLE |
2104 ms |
3456 KiB |
| 01-21.txt |
TLE |
2103 ms |
3456 KiB |
| 01-22.txt |
TLE |
2103 ms |
7104 KiB |
| 01-23.txt |
TLE |
2104 ms |
7108 KiB |
| 01-24.txt |
TLE |
2103 ms |
7188 KiB |
| 01-25.txt |
TLE |
2107 ms |
67460 KiB |
| 01-26.txt |
TLE |
2108 ms |
68972 KiB |
| 01-27.txt |
TLE |
2108 ms |
69044 KiB |
| 01-28.txt |
TLE |
2104 ms |
3328 KiB |
| 01-29.txt |
TLE |
2103 ms |
3328 KiB |
| 01-30.txt |
AC |
93 ms |
22536 KiB |
| sample-01.txt |
AC |
1 ms |
256 KiB |
| sample-02.txt |
AC |
1 ms |
256 KiB |
| sample-03.txt |
AC |
1 ms |
256 KiB |
| sample-04.txt |
AC |
1 ms |
256 KiB |