QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#116082 | #5280. Depot Rearrangement | zhouhuanyi# | 5 | 68ms | 25880kb | C++11 | 1.7kb | 2023-06-28 09:02:21 | 2024-05-31 14:20:23 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define N 800
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
struct reads
{
int num,data;
};
struct node
{
int x,y;
};
node st[N*N+1];
int n,m,leng,lengths,res,a[N*N+1],cnt[N+1],cur[N+1],tong[N+1],length;
vector<reads>E[N+1];
bool used[N*N+1];
void add(int x,int y)
{
++leng,E[x].push_back((reads){y,leng});
return;
}
void adder(int x,int y)
{
swap(a[x],a[y]),st[++lengths]=(node){x,y};
return;
}
void dfs(int x)
{
for (int &i=cur[x],t;i<E[x].size();++i)
if (!used[E[x][i].data])
t=E[x][i].data,used[t]=1,dfs(E[x][i].num),tong[++length]=x;
return;
}
int main()
{
int x;
vector<int>A;
vector<int>B;
n=read(),m=read();
for (int i=1;i<=n*m;++i) a[i]=read();
for (int i=1;i<=m;++i)
{
A.clear(),B.clear();
for (int j=1;j<=n;++j) cnt[j]=0;
for (int j=1;j<=n*m;++j)
if (a[j]==i)
cnt[(j-1)/m+1]++;
for (int j=1;j<=n;++j)
{
if (cnt[j]>1)
{
for (int k=1;k<=cnt[j]-1;++k) add(j,n+i);
}
else if (!cnt[j]) add(n+i,j);
}
}
for (int i=1;i<=n;++i)
{
length=0,dfs(i);
if (length)
{
reverse(tong+1,tong+length+1);
for (int i=1;i<=length;i+=2)
{
x=0;
for (int j=(tong[i]-1)*m+1;j<=tong[i]*m;++j)
if (a[j]==tong[i+1]-n)
x=j;
adder(x,n*m+1);
}
for (int i=(tong[1]-1)*m+1;i<=tong[1]*m;++i)
if (!a[i])
x=i;
adder(x,n*m+1);
}
}
printf("%d\n",lengths);
for (int i=1;i<=lengths;++i) printf("%d %d\n",st[i].x,st[i].y);
return 0;
}
詳細信息
Test #1:
score: 5
Accepted
time: 1ms
memory: 5864kb
input:
10 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
output:
0
result:
ok both subtasks are correct!
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 5692kb
input:
5 4 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4
output:
13 4 21 10 21 3 21 15 21 2 21 20 21 8 21 14 21 7 21 19 21 12 21 18 21 4 21
result:
wrong output format Extra information in the output file
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 7924kb
input:
10 10 8 10 10 3 7 3 5 6 1 4 3 8 2 9 1 8 4 2 7 3 10 7 9 2 1 10 10 9 1 2 9 7 4 5 2 9 10 5 7 6 6 8 6 8 4 2 9 1 2 8 6 1 4 2 2 1 5 6 3 10 10 7 9 4 8 9 8 2 5 6 4 3 1 6 3 3 10 7 7 5 3 6 8 5 9 4 6 7 9 4 10 5 3 4 5 1 1 7 8 5
output:
32 6 101 29 101 38 101 18 101 3 101 20 101 39 101 49 101 76 101 43 101 16 101 30 101 90 101 28 101 56 101 67 101 36 101 75 101 66 101 97 101 87 101 27 101 50 101 55 101 100 101 44 101 79 101 58 101 95 101 26 101 89 101 6 101
result:
wrong output format Extra information in the output file
Test #4:
score: 0
Wrong Answer
time: 1ms
memory: 5848kb
input:
100 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 9 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10...
output:
19 109 1001 819 1001 713 1001 734 1001 850 1001 210 1001 175 1001 830 1001 670 1001 775 1001 359 1001 949 1001 814 1001 184 1001 453 1001 109 1001 707 1001 747 1001 707 1001
result:
wrong output format Extra information in the output file
Test #5:
score: 0
Wrong Answer
time: 2ms
memory: 6168kb
input:
200 100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...
output:
195 273 20001 2648 20001 11540 20001 15165 20001 5034 20001 3334 20001 3971 20001 3641 20001 4955 20001 7854 20001 10354 20001 12213 20001 3013 20001 12259 20001 459 20001 17871 20001 5065 20001 7398 20001 3761 20001 5861 20001 4233 20001 3784 20001 6061 20001 5159 20001 1488 20001 14250 20001 9050 ...
result:
wrong output format Extra information in the output file
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 8320kb
input:
201 20 20 18 5 5 1 7 8 17 12 10 20 12 13 19 16 2 9 8 20 20 19 10 17 20 9 11 15 17 9 2 3 4 17 10 7 20 7 19 17 11 20 2 1 13 11 9 11 6 10 8 11 3 2 16 9 15 16 12 13 6 5 13 4 13 3 8 20 18 10 3 14 1 11 20 17 17 2 11 20 1 4 10 3 3 9 13 7 10 19 16 14 16 9 19 14 15 12 9 20 12 2 19 18 2 7 7 2 12 10 8 20 18 16...
output:
1401 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 417 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 499 4021 0 4021 380 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 4021 0 ...
result:
wrong answer Integer 0 violates the range [1, 4021]
Test #7:
score: 0
Wrong Answer
time: 19ms
memory: 7912kb
input:
300 300 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...
output:
205 1262 90001 57670 90001 82270 90001 57662 90001 42644 90001 13556 90001 54956 90001 20910 90001 85710 90001 58544 90001 61771 90001 27271 90001 16610 90001 30110 90001 16685 90001 65959 90001 21859 90001 20359 90001 77959 90001 3259 90001 58459 90001 65885 90001 16773 90001 26374 90001 19174 9000...
result:
wrong output format Extra information in the output file
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 9628kb
input:
301 40 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
11624 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 12041 0 1204...
result:
wrong answer Integer 0 violates the range [1, 12041]
Test #9:
score: 0
Wrong Answer
time: 0ms
memory: 10124kb
input:
400 100 11 65 1 79 15 18 79 46 9 30 71 53 58 55 94 73 39 16 6 91 49 30 23 30 28 81 90 48 97 54 79 30 94 18 42 77 44 36 5 48 55 97 79 36 41 59 79 71 32 59 3 10 63 52 44 41 9 46 31 31 56 87 60 80 12 51 15 78 41 65 95 34 29 83 46 64 37 53 98 17 41 45 36 73 20 53 48 80 57 54 57 72 39 56 98 6 10 78 11 72...
output:
14592 0 40001 0 40001 0 40001 0 40001 0 40001 0 40001 701 40001 0 40001 0 40001 0 40001 0 40001 0 40001 1061 40001 0 40001 541 40001 0 40001 0 40001 0 40001 0 40001 0 40001 83 40001 467 40001 539 40001 0 40001 169 40001 0 40001 0 40001 0 40001 0 40001 699 40001 0 40001 0 40001 0 40001 429 40001 67 4...
result:
wrong answer Integer 0 violates the range [1, 40001]
Test #10:
score: 0
Wrong Answer
time: 2ms
memory: 8080kb
input:
40 160 17 2 3 4 5 6 7 91 9 10 154 12 103 14 15 16 17 25 19 58 21 8 23 24 52 26 27 58 120 105 50 55 104 32 35 36 37 38 45 10 41 42 43 44 45 71 47 48 49 34 140 52 53 54 115 44 28 58 59 60 61 62 63 64 132 66 67 68 69 70 71 69 24 74 75 76 77 133 79 80 81 82 100 84 31 86 87 88 100 90 91 92 93 94 95 96 97...
output:
1316 0 6401 338 6401 0 6401 0 6401 806 6401 977 6401 2009 6401 15 6401 2238 6401 1428 6401 1034 6401 839 6401 234 6401 353 6401 41 6401 276 6401 750 6401 510 6401 1119 6401 757 6401 109 6401 2417 6401 3288 6401 534 6401 1581 6401 2337 6401 281 6401 938 6401 1025 6401 396 6401 191 6401 0 6401 245 640...
result:
wrong answer Integer 0 violates the range [1, 6401]
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 8196kb
input:
400 100 88 82 9 2 90 1 83 32 32 79 8 79 63 67 85 82 50 63 69 2 7 91 21 90 69 3 39 78 66 83 96 53 24 65 56 63 90 54 35 55 94 22 76 12 54 55 5 49 91 73 8 19 64 54 39 23 13 27 34 4 81 52 13 11 36 45 3 50 82 81 42 50 75 15 99 70 29 26 70 66 34 15 42 83 16 19 19 12 76 1 68 49 7 17 64 37 98 34 99 37 34 64...
output:
14611 0 40001 0 40001 179 40001 0 40001 437 40001 0 40001 0 40001 177 40001 0 40001 0 40001 0 40001 0 40001 0 40001 69 40001 0 40001 0 40001 0 40001 0 40001 0 40001 547 40001 0 40001 0 40001 0 40001 0 40001 0 40001 0 40001 0 40001 0 40001 0 40001 287 40001 0 40001 0 40001 0 40001 0 40001 0 40001 0 4...
result:
wrong answer Integer 0 violates the range [1, 40001]
Test #12:
score: 0
Wrong Answer
time: 2ms
memory: 8820kb
input:
301 20 8 1 1 1 1 1 1 17 1 9 1 5 1 1 1 1 13 1 9 1 18 1 1 16 1 15 5 19 1 8 11 10 1 1 1 1 18 4 1 1 1 1 16 1 1 1 12 10 1 1 1 14 11 13 1 1 1 1 1 1 10 1 1 1 1 1 1 19 14 1 1 1 5 1 1 1 1 13 1 18 1 1 4 1 1 1 1 1 1 1 1 1 1 16 16 10 1 14 18 1 1 1 7 1 1 1 1 6 9 1 13 1 1 1 2 1 1 1 1 1 1 10 1 1 1 17 1 10 10 1 12 ...
output:
4260 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 397 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 0 6021 103 6021 0 6021 0 6021 817 6021 0 6021 0 ...
result:
wrong answer Integer 0 violates the range [1, 6021]
Test #13:
score: 0
Wrong Answer
time: 29ms
memory: 12756kb
input:
300 300 215 159 263 206 201 183 286 56 142 10 231 214 34 54 263 250 169 208 239 148 104 22 244 17 74 68 184 52 2 30 42 83 222 106 25 152 37 225 213 213 69 273 91 221 207 48 166 28 221 50 46 64 10 254 207 109 206 144 270 291 195 197 253 235 141 186 102 68 52 24 38 6 181 44 256 200 77 233 285 163 223 ...
output:
32648 181 90001 833 90001 0 90001 0 90001 1745 90001 289 90001 2541 90001 609 90001 3215 90001 0 90001 75 90001 1045 90001 0 90001 2083 90001 0 90001 1405 90001 5451 90001 901 90001 0 90001 0 90001 0 90001 787 90001 375 90001 1237 90001 171 90001 3363 90001 0 90001 87 90001 865 90001 145 90001 539 9...
result:
wrong output format Extra information in the output file
Test #14:
score: 0
Wrong Answer
time: 41ms
memory: 17748kb
input:
201 400 1 1 1 1 1 152 1 1 1 1 1 1 1 33 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 300 154 1 1 147 1 1 1 383 186 1 1 90 256 1 1 1 1 1 1 1 63 1 1 1 1 208 1 1 1 1 31 1 1 1 1 1 1 1 127 1 1 29 216 397 393 1 1 1 1 1 1 279 1 1 1 1 55 1 1 215 249 1 1 1 1 1 1 172 1 1 1 1 1 1 1 1 1 1 1 1 349 1 331 1 1 1 1 1 1 1 34...
output:
63990 363 80401 737 80401 275 80401 1173 80401 253 80401 1565 80401 1921 80401 245 80401 1875 80401 701 80401 941 80401 1487 80401 2279 80401 209 80401 2267 80401 659 80401 1361 80401 2619 80401 133 80401 2571 80401 411 80401 1871 80401 895 80401 0 80401 2195 80401 0 80401 2153 80401 0 80401 3399 80...
result:
wrong output format Extra information in the output file
Test #15:
score: 0
Wrong Answer
time: 41ms
memory: 8344kb
input:
400 400 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...
output:
217 784 160001 118784 160001 784 160001 2922 160001 11722 160001 3172 160001 115020 160001 45736 160001 12909 160001 132351 160001 94351 160001 8955 160001 90073 160001 83273 160001 83888 160001 48288 160001 90155 160001 119963 160001 33061 160001 7861 160001 139569 160001 36721 160001 126703 160001...
result:
wrong output format Extra information in the output file
Test #16:
score: 0
Wrong Answer
time: 12ms
memory: 11392kb
input:
301 200 50 129 146 60 183 51 47 77 26 73 1 45 1 44 149 1 81 196 17 16 163 35 159 71 1 94 161 138 138 27 76 1 102 42 5 186 176 1 111 198 37 63 81 155 95 164 132 135 155 194 126 98 31 34 121 19 175 148 33 105 25 122 91 165 1 69 1 197 12 98 1 155 5 53 42 1 60 98 78 61 155 13 1 171 102 152 95 61 87 200 ...
output:
23506 133 60201 795 60201 0 60201 0 60201 0 60201 0 60201 0 60201 0 60201 0 60201 439 60201 0 60201 731 60201 575 60201 0 60201 0 60201 1955 60201 0 60201 1939 60201 0 60201 0 60201 2123 60201 0 60201 0 60201 2587 60201 0 60201 6513 60201 0 60201 0 60201 2695 60201 0 60201 0 60201 7195 60201 0 60201...
result:
wrong output format Extra information in the output file
Test #17:
score: 0
Wrong Answer
time: 50ms
memory: 19568kb
input:
201 400 1 1 1 1 1 1 1 1 1 1 1 1 1 263 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 246 1 1 1 1 1 1 1 1 1 1 1 1 1 1 107 1 1 1 1 1 1 1 1 57 1 1 1 1 1 1 1 224 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 90 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
77869 389 80401 849 80401 349 80401 1579 80401 273 80401 1969 80401 201 80401 2067 80401 177 80401 2771 80401 173 80401 2945 80401 169 80401 3577 80401 0 80401 3863 80401 0 80401 0 80401 0 80401 4755 80401 0 80401 5049 80401 0 80401 5475 80401 0 80401 5815 80401 655 80401 0 80401 1575 80401 663 8040...
result:
wrong output format Extra information in the output file
Test #18:
score: 0
Wrong Answer
time: 35ms
memory: 14896kb
input:
400 300 75 26 289 176 131 196 124 8 230 157 247 265 13 2 210 141 17 200 187 83 21 22 118 144 232 26 284 75 48 30 132 32 65 34 72 36 73 286 164 40 41 261 65 270 221 12 139 48 49 143 91 39 17 258 275 56 151 194 282 55 228 266 296 64 22 232 67 142 69 152 10 102 109 45 75 49 283 112 78 283 81 236 169 22...
output:
43105 293 120001 501 120001 265 120001 493 120001 1799 120001 801 120001 1217 120001 0 120001 497 120001 721 120001 261 120001 4037 120001 1393 120001 4545 120001 485 120001 897 120001 0 120001 1385 120001 1747 120001 893 120001 4581 120001 2611 120001 0 120001 889 120001 0 120001 1087 120001 487 12...
result:
wrong output format Extra information in the output file
Test #19:
score: 0
Wrong Answer
time: 68ms
memory: 25880kb
input:
333 399 1 1 1 1 1 1 1 28 1 1 1 1 1 1 161 1 17 1 1 1 1 262 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 43 1 1 1 1 1 70 1 1 1 142 1 1 1 1 1 1 1 1 1 1 1 1 70 1 1 1 1 1 1 278 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 245 1 1 1 1 1 1 33 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 106 1 1 1 1 268 1 1 1 172 1 1 1 1 1 312 1 286 1 1 1 1 ...
output:
114795 327 132868 777 132868 1193 132868 1579 132868 249 132868 1571 132868 773 132868 1567 132868 1993 132868 245 132868 1965 132868 765 132868 1825 132868 1155 132868 1795 132868 2389 132868 241 132868 2343 132868 757 132868 2229 132868 1133 132868 2339 132868 237 132868 2767 132868 233 132868 296...
result:
wrong output format Extra information in the output file
Test #20:
score: 0
Wrong Answer
time: 55ms
memory: 16780kb
input:
400 400 100 35 353 385 317 228 7 148 113 165 11 306 209 89 21 166 17 2 19 249 27 305 377 22 3 353 38 28 29 96 191 32 33 309 35 308 100 176 152 40 176 42 43 86 45 46 96 48 396 381 218 246 53 54 334 159 243 360 294 60 33 62 185 64 65 66 191 121 351 107 10 343 367 74 75 201 77 247 79 134 304 92 42 126 ...
output:
55816 147 160001 799 160001 1441 160001 775 160001 2343 160001 69 160001 1975 160001 579 160001 355 160001 1059 160001 4117 160001 2135 160001 1789 160001 1563 160001 1163 160001 0 160001 5229 160001 3063 160001 0 160001 0 160001 0 160001 0 160001 0 160001 689 160001 2393 160001 3165 160001 177 1600...
result:
wrong output format Extra information in the output file