Submission #8815594
Source Code Expand
#include <bits/stdc++.h> #pragma GCC optimize ("O2") #pragma GCC optimize ("unroll-loops") //#pragma GCC optimize("no-stack-protector,fast-math") using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<pii, int> piii; typedef pair<ll, ll> pll; #define debug(x) cerr<<#x<<'='<<(x)<<endl; #define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl; #define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl; #define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl; #define all(x) x.begin(), x.end() #define pb push_back #define kill(x) return cout<<x<<'\n', 0; const ld eps=1e-7; const int inf=1000000010; const ll INF=10000000000000010LL; const int mod = 1000000007; const int MAXN = 100010, LOG=20; int n, m, k, u, v, x, y, t, a, b, ans; int P[MAXN]; int deg[MAXN]; vector<int> G[MAXN]; set<pii> st; priority_queue<int, vector<int>, greater<int>> pq; void add_edge(int u, int v){ if (!u || v==n+1) return ; G[u].pb(v); deg[v]++; //debug2(u, v) } int main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin>>n>>k; st.insert({0, 0}); st.insert({n+1, n+1}); for (int i=1; i<=n; i++){ cin>>P[i]; if (i>k) st.erase({P[i-k], i-k}); auto it=st.lower_bound({P[i], 0}); add_edge(i, it->second); it--; add_edge(it->second, i); st.insert({P[i], i}); } for (int i=1; i<=n; i++) if (!deg[i]) pq.push(i); while (pq.size()){ int v=pq.top(); pq.pop(); cout<<v<<'\n'; for (int u:G[v]) if (!--deg[u]) pq.push(u); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Wide Swap |
User | alishahali1382 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1719 Byte |
Status | RE |
Exec Time | 170 ms |
Memory | 11264 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 2000 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, 057.txt, 058.txt, 059.txt, 060.txt, 061.txt, 062.txt, 063.txt, 064.txt, 065.txt, 066.txt, 067.txt, 068.txt, 069.txt, 070.txt, 071.txt, 072.txt, 073.txt, 074.txt, 075.txt, 076.txt, 077.txt, 078.txt, 079.txt, 080.txt, 081.txt, 082.txt, 083.txt, 084.txt, 085.txt, 086.txt, 087.txt, 088.txt, 089.txt, 090.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 2 ms | 2560 KB |
001.txt | AC | 2 ms | 2560 KB |
002.txt | AC | 2 ms | 2560 KB |
003.txt | AC | 2 ms | 2560 KB |
004.txt | AC | 2 ms | 2560 KB |
005.txt | WA | 2 ms | 2560 KB |
006.txt | WA | 2 ms | 2560 KB |
007.txt | WA | 2 ms | 2560 KB |
008.txt | WA | 2 ms | 2560 KB |
009.txt | WA | 3 ms | 2688 KB |
010.txt | WA | 3 ms | 2688 KB |
011.txt | WA | 4 ms | 2688 KB |
012.txt | WA | 3 ms | 2688 KB |
013.txt | WA | 3 ms | 2688 KB |
014.txt | WA | 3 ms | 2688 KB |
015.txt | WA | 3 ms | 2688 KB |
016.txt | WA | 3 ms | 2688 KB |
017.txt | WA | 3 ms | 2688 KB |
018.txt | WA | 3 ms | 2816 KB |
019.txt | WA | 3 ms | 2688 KB |
020.txt | WA | 2 ms | 2688 KB |
021.txt | WA | 3 ms | 2688 KB |
022.txt | WA | 3 ms | 2688 KB |
023.txt | WA | 3 ms | 2688 KB |
024.txt | WA | 3 ms | 2688 KB |
025.txt | WA | 3 ms | 2688 KB |
026.txt | WA | 3 ms | 2688 KB |
027.txt | WA | 3 ms | 2688 KB |
028.txt | WA | 3 ms | 2688 KB |
029.txt | AC | 3 ms | 2688 KB |
030.txt | WA | 3 ms | 2816 KB |
031.txt | AC | 3 ms | 2688 KB |
032.txt | WA | 3 ms | 2816 KB |
033.txt | WA | 3 ms | 2688 KB |
034.txt | WA | 3 ms | 2816 KB |
035.txt | WA | 3 ms | 2688 KB |
036.txt | WA | 3 ms | 2816 KB |
037.txt | WA | 3 ms | 2688 KB |
038.txt | WA | 3 ms | 2816 KB |
039.txt | RE | 120 ms | 5504 KB |
040.txt | RE | 144 ms | 6528 KB |
041.txt | RE | 166 ms | 7040 KB |
042.txt | RE | 154 ms | 6656 KB |
043.txt | RE | 165 ms | 6912 KB |
044.txt | RE | 158 ms | 11264 KB |
045.txt | RE | 129 ms | 6400 KB |
046.txt | RE | 158 ms | 11264 KB |
047.txt | RE | 157 ms | 6656 KB |
048.txt | RE | 134 ms | 6528 KB |
049.txt | RE | 135 ms | 6400 KB |
050.txt | RE | 159 ms | 6656 KB |
051.txt | RE | 147 ms | 6528 KB |
052.txt | RE | 170 ms | 7168 KB |
053.txt | AC | 34 ms | 4088 KB |
054.txt | RE | 158 ms | 6656 KB |
055.txt | WA | 4 ms | 2688 KB |
056.txt | WA | 35 ms | 5376 KB |
057.txt | RE | 140 ms | 6528 KB |
058.txt | WA | 44 ms | 5632 KB |
059.txt | RE | 115 ms | 2944 KB |
060.txt | RE | 158 ms | 11264 KB |
061.txt | RE | 119 ms | 5504 KB |
062.txt | RE | 158 ms | 11264 KB |
063.txt | RE | 122 ms | 5888 KB |
064.txt | RE | 158 ms | 11264 KB |
065.txt | RE | 123 ms | 6016 KB |
066.txt | RE | 158 ms | 11264 KB |
067.txt | RE | 125 ms | 6144 KB |
068.txt | RE | 158 ms | 11264 KB |
069.txt | RE | 131 ms | 6528 KB |
070.txt | RE | 133 ms | 8576 KB |
071.txt | RE | 137 ms | 6656 KB |
072.txt | RE | 122 ms | 6016 KB |
073.txt | RE | 139 ms | 7168 KB |
074.txt | RE | 119 ms | 5504 KB |
075.txt | RE | 144 ms | 7424 KB |
076.txt | RE | 141 ms | 8192 KB |
077.txt | RE | 138 ms | 7168 KB |
078.txt | RE | 136 ms | 7168 KB |
079.txt | RE | 134 ms | 9344 KB |
080.txt | WA | 11 ms | 3584 KB |
081.txt | WA | 24 ms | 5376 KB |
082.txt | RE | 140 ms | 7936 KB |
083.txt | WA | 42 ms | 7936 KB |
084.txt | WA | 39 ms | 6656 KB |
085.txt | WA | 36 ms | 5632 KB |
086.txt | WA | 11 ms | 3456 KB |
087.txt | RE | 139 ms | 6656 KB |
088.txt | WA | 38 ms | 7040 KB |
089.txt | RE | 113 ms | 3072 KB |
090.txt | RE | 123 ms | 6528 KB |
sample-01.txt | AC | 2 ms | 2560 KB |
sample-02.txt | AC | 2 ms | 2560 KB |
sample-03.txt | AC | 2 ms | 2560 KB |