QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#217192 | #5113. Bridge | ucup-team1001 | RE | 56ms | 517976kb | C++20 | 2.0kb | 2023-10-16 16:29:34 | 2023-10-16 16:29:34 |
Judging History
answer
#include<bits/stdc++.h>
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
#define irep(i,l,r) for(int i = l; i <= r; ++ i)
const int N = 100099;
const int len = 570;
const int K = N / len + 50;
int per[N][655],invp[N][655];
struct stak{
int tot;
int opt[500][2];
stak(){tot = 0;}
void push(int x,int y){
opt[++ tot][0] = x, opt[tot][1] = y;
}
void top(int &x, int &y){
x = opt[tot][0], y = opt[tot][1];
}
void pop(){
-- tot;
}
int size(){
return tot;
}
};
stak p[655];
// clo, line
inline int read(){
char ch = getchar();
int s = 0;
while(!isdigit(ch))ch = getchar();
while(isdigit(ch))s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
return s;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n = read(), m = read(), q = read();
for(int c = 0; c <= m / len; c ++){
for(int i = 1; i <= n; ++ i){
per[i][c] = invp[i][c] = i;
}
}
while(q --){
int op = read();
if(op == 1){
int line = read(), cloumn = read();
int x = cloumn / len;
// array<int, 2> PI = {cloumn, line};
stak temp;
while(p[x].size()){
int c, l;
p[x].top(c, l);
// auto [c, l] = p[x].top();
if(c < cloumn)break;
int tx, ty;
p[x].top(tx, ty);
// temp.push(p[x].top());
temp.push(tx, ty);
per[invp[l][x]][x] = l + 1;
per[invp[l + 1][x]][x] = l;
swap(invp[l][x], invp[l + 1][x]);
p[x].pop();
}
temp.push(cloumn, line);
while(temp.size()){
int c, l;
temp.top(c, l);
per[invp[l][x]][x] = l + 1;
per[invp[l + 1][x]][x] = l;
swap(invp[l][x], invp[l + 1][x]);
int tx, ty;
temp.top(tx, ty);
// temp.push(p[x].top());
p[x].push(tx, ty);
temp.pop();
}
}
else{
int a = read();
for(int x = 0; x <= m / len; ++ x){
a = per[a][x];
}
cout << a << '\n';
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 8928kb
input:
3 4 13 2 2 1 1 3 2 1 2 2 2 3 1 2 4 2 1 2 2 2 3 1 2 1 2 1 2 2 2 3
output:
2 2 1 3 3 1 2 3 2 1
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 56ms
memory: 9624kb
input:
3 100000 99997 2 2 2 2 2 3 2 3 2 3 2 3 2 3 1 2 11047 1 1 98732 1 2 90045 1 1 43556 2 1 2 3 1 2 17242 1 1 17027 2 1 1 1 94195 2 1 2 2 2 1 2 3 1 1 34124 1 2 14354 1 2 673 1 2 39812 1 2 35520 1 2 16046 2 3 2 2 1 1 25410 2 3 2 1 2 3 2 2 1 2 55684 2 1 1 2 24811 1 2 92268 1 2 60268 2 2 1 1 89272 1 2 19232...
output:
2 2 3 3 3 3 3 3 2 1 2 1 2 3 3 1 1 2 1 3 3 2 1 3 2 1 2 1 2 2 2 2 1 1 2 1 3 2 1 3 2 1 3 2 2 1 3 3 2 3 2 3 1 2 1 1 2 3 2 1 3 2 3 2 3 2 2 1 1 2 1 1 2 3 2 1 1 3 1 1 2 2 3 2 2 1 1 1 2 3 3 1 1 2 1 1 3 1 3 2 3 2 3 2 2 2 3 3 2 2 2 3 3 2 2 2 3 1 2 1 1 3 2 3 2 2 2 1 1 1 3 3 3 2 1 1 3 3 3 1 1 2 3 2 3 3 3 3 2 3 ...
result:
ok 60761 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 517976kb
input:
100000 5 20 1 40277 1 2 55431 2 22404 2 29137 2 10206 2 72758 2 92880 1 96104 2 2 12641 1 99618 2 2 88481 1 76531 3 1 91957 5 1 23999 2 2 35922 1 69730 5 1 16353 2 1 90312 1 1 75264 5 2 77283
output:
55431 22404 29137 10206 72758 92880 12641 88481 35922 77283
result:
ok 10 numbers
Test #4:
score: 0
Accepted
time: 2ms
memory: 9964kb
input:
3 5 20 2 3 1 2 2 2 3 1 1 4 2 1 1 2 5 1 1 1 2 1 2 2 2 1 2 1 2 2 2 3 2 3 2 1 2 1 2 1 2 3 2 2 2 3
output:
3 2 2 2 3 2 2 3 1 1 2 2 2 1 3 1
result:
ok 16 numbers
Test #5:
score: 0
Accepted
time: 55ms
memory: 12632kb
input:
200 100000 99995 1 180 45150 2 137 1 97 78979 1 14 74747 1 151 41036 1 178 88736 1 26 50618 1 132 72623 1 95 37475 2 184 1 31 44675 1 183 14874 1 66 14597 2 191 2 102 1 27 61558 1 36 39304 2 119 2 185 1 156 50000 2 200 2 152 1 17 51778 1 39 39403 2 168 1 50 67213 1 92 56771 2 28 2 196 1 99 29006 2 4...
output:
137 184 191 102 119 185 200 151 168 27 196 43 73 16 28 64 88 106 139 117 90 131 64 64 107 11 38 149 133 184 166 20 95 185 71 85 151 96 106 103 91 45 195 112 82 113 183 178 47 112 12 185 41 153 77 179 44 165 84 111 192 161 144 33 139 9 37 38 177 45 146 83 88 166 1 180 175 180 12 166 186 44 2 115 124 ...
result:
ok 50281 numbers
Test #6:
score: -100
Runtime Error
input:
200 100 100000 1 192 88 1 13 2 2 131 1 80 44 1 11 74 1 159 89 1 29 91 1 81 62 1 159 21 1 37 34 2 169 2 163 1 164 50 1 104 45 1 81 46 1 176 73 1 68 59 2 117 2 152 2 189 1 125 4 2 45 1 120 59 2 30 2 113 1 74 15 1 147 71 1 31 47 2 179 2 118 2 34 2 61 1 41 32 2 153 1 186 28 2 113 2 55 2 24 2 92 2 72 2 8...