QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#2661 | #11. 矩阵变换 | zombie462 | 0 | 0ms | 0kb | C++17 | 1.1kb | 2022-04-26 08:35:18 | 2022-04-26 08:35:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define N 210
int read(){
int x=0,f=1;
char ch=getchar();
while (ch<'0' || ch>'9'){
if (ch=='-') f=-1;
ch=getchar();
}
while (ch>='0' && ch<='9'){
x=x*10+ch-'0';ch=getchar();
}
return x*f;
}
class StableMatching{
public:
int girl[N][N],boy[N][N];
int girlc[N],boyc[N];
int n,m;
queue <int> q;
int solve(){
for (int i=1;i<=n;++i) boy[i][n+1]=0,boyc[i]=n+1,girlc[i]=1,q.push(i);
while (!q.empty()){
int G=q.front(),B=girl[G][girlc[G]];
if (boy[B][boyc[B]]<boy[B][G]){
q.pop();
if (boyc[B]!=n+1){
girlc[boyc[B]]++;
q.push(boyc[B]);
}
boyc[B]=G;
}else girlc[G]++;
}
for (int i=1;i<n;++i) printf("%d ",girl[i][girlc[i]]);
printf("%d\n",girl[n][girlc[n]]);
}
}GSA;
signed main(){
int T=read();
while (T --> 0){
GSA.n=read();GSA.m=read();
for (int i=1;i<=GSA.n;++i){
int tot=0;
for (int j=1;j<=GSA.m;++j){
int x=read();
if (x){
GSA.girl[i][++tot]=x;
GSA.boy[x][i]=j;
}
}
}
GSA.solve();
}
return 0;
}
详细
Test #1:
score: 0
Dangerous Syscalls
input:
5 3 5 2 0 3 1 0 3 0 1 0 2 0 1 2 3 0 3 5 2 3 1 0 0 0 1 0 2 3 1 0 3 0 2 3 5 0 3 2 0 1 2 0 0 1 3 0 1 3 2 0 3 5 0 2 0 3 1 2 1 0 0 3 3 0 0 1 2 3 5 0 2 3 0 1 3 0 0 1 2 2 1 0 0 3
output:
result:
Test #2:
score: 0
Dangerous Syscalls
input:
7 4 7 2 0 1 3 0 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0 7 10 0 0 0 0 0 0 0 0 0 22 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 14 0 0 0 15 0 0 0 17 0 24 0 0 0 0 12 13 0 0 0 0 0 0 0 23 0 0 1 0 0 0 0 0 ...
output:
result:
Test #6:
score: 0
Dangerous Syscalls
input:
20 80 250 0 14 0 0 0 0 0 53 0 16 5 0 0 0 0 0 31 49 0 0 0 6 33 18 30 57 0 0 0 0 79 51 0 0 19 0 29 21 0 24 0 0 0 0 0 43 0 28 0 0 12 0 0 71 0 0 0 50 45 0 0 47 0 0 0 35 58 0 0 0 0 0 1 0 0 39 0 0 41 0 55 25 0 0 0 0 54 4 0 27 0 0 9 0 0 80 0 0 0 0 0 10 74 0 75 0 0 0 69 0 0 0 0 0 20 0 0 0 0 0 0 0 0 15 0 63 ...
output:
result:
Test #7:
score: 0
Dangerous Syscalls
input:
30 120 300 0 0 0 15 112 0 0 0 89 0 61 13 0 6 0 4 0 24 0 98 0 32 88 0 0 43 35 0 21 0 0 0 87 0 0 0 52 76 42 0 59 97 0 0 0 51 0 0 104 0 67 0 94 53 120 105 33 0 106 45 80 39 14 62 116 5 0 0 69 27 0 25 0 0 0 0 20 101 0 0 0 0 0 0 0 0 18 0 0 0 0 0 0 31 0 83 0 0 0 0 41 49 90 36 0 0 0 0 0 0 0 0 0 0 73 0 2 84...
output:
result:
Test #8:
score: 0
Dangerous Syscalls
input:
40 160 360 60 0 0 0 132 0 2 0 128 126 0 0 89 0 0 61 156 0 0 154 0 134 0 73 100 0 21 0 117 0 0 0 0 0 15 125 0 0 0 0 115 108 0 0 0 80 0 40 0 5 92 0 0 0 87 0 0 0 0 63 0 0 109 0 114 112 113 129 0 0 0 0 28 157 20 91 138 0 0 98 88 136 67 110 0 0 0 0 29 0 0 10 106 0 0 96 0 0 11 152 23 0 0 54 37 0 38 0 0 12...
output:
result:
Test #9:
score: 0
Dangerous Syscalls
input:
45 190 390 107 0 190 0 70 7 0 0 0 43 0 133 158 0 118 171 127 0 0 164 25 0 0 99 0 0 189 84 0 27 0 57 0 147 0 34 0 0 180 114 130 0 0 0 0 0 79 35 0 119 0 0 54 0 0 0 0 128 0 0 0 44 0 51 0 0 97 24 23 0 148 168 166 36 0 167 0 0 0 104 0 55 0 0 122 0 47 0 0 0 0 139 0 0 22 0 0 108 67 0 0 0 161 20 0 150 103 8...
output:
result:
Test #10:
score: 0
Dangerous Syscalls
input:
49 199 399 89 167 78 0 112 139 0 0 17 179 0 35 113 0 0 0 0 0 5 0 138 0 0 76 147 58 0 43 0 38 0 0 0 0 0 0 48 86 178 81 19 157 118 0 0 123 0 151 68 125 61 198 74 0 0 99 124 0 0 0 49 0 155 145 132 85 0 0 0 166 0 189 0 120 0 0 41 4 127 0 0 88 0 0 0 25 134 154 0 44 0 91 136 102 33 0 0 0 51 143 0 181 0 0 ...