#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
multiset<ll> stuff[100005];
vector<ll> ans[100005];
bool used[100005];
map<ll,ll> match;
vector<ll> reals;
bool khun(ll a){
if (used[a]) return false;
used[a] = true;
for (auto&i : stuff[a]){
if (match.count(i)==0 || khun(match[i])){
match[i] = a;
return true;
}
}
return false;
}
ll cnts[100005];
int main(){
FOR(i,0,100005) match[i] = -1, used[i] = false, cnts[i] = 0;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,s,t;
cin >> n >> s >> t;
vector<vector<ll>> cores;
vector<vector<ll>> orient(n);
ll cnt = 0;
FOR(i,0,n){
FOR(j,0,s){
ll temp;
cin >> temp;
cnts[temp]++;
ll idk = ((cnts[temp]-1)/s)*1000000 + temp;
stuff[i].insert(idk);
reals.push_back(temp);
}
}
FOR(i,0,s){
match.clear();
FOR(j,0,n){
FOR(p,0,n+1) used[p] = false;
khun(j);
}
for (auto&i : match){
ans[i.second].push_back(i.first%1000000);
stuff[i.second].erase(stuff[i.second].find(i.first));
}
}
FOR(i,0,n){
for (auto&k : ans[i])cout << k << " ";
cout << "\n";
}
}
Compilation message
balance.cpp: In function 'int main()':
balance.cpp:43:5: warning: unused variable 'cnt' [-Wunused-variable]
43 | ll cnt = 0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
14648 KB |
Correct |
2 |
Correct |
20 ms |
14428 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
14428 KB |
Correct |
2 |
Incorrect |
20 ms |
14428 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
895 ms |
33204 KB |
Correct |
2 |
Correct |
1106 ms |
35008 KB |
Correct |
3 |
Correct |
1083 ms |
31156 KB |
Correct |
4 |
Correct |
521 ms |
28828 KB |
Correct |
5 |
Correct |
1238 ms |
38076 KB |
Correct |
6 |
Correct |
852 ms |
36604 KB |
Correct |
7 |
Correct |
697 ms |
30148 KB |
Correct |
8 |
Execution timed out |
2065 ms |
29676 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
895 ms |
33204 KB |
Correct |
2 |
Correct |
1106 ms |
35008 KB |
Correct |
3 |
Correct |
1083 ms |
31156 KB |
Correct |
4 |
Correct |
521 ms |
28828 KB |
Correct |
5 |
Correct |
1238 ms |
38076 KB |
Correct |
6 |
Correct |
852 ms |
36604 KB |
Correct |
7 |
Correct |
697 ms |
30148 KB |
Correct |
8 |
Execution timed out |
2065 ms |
29676 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
14428 KB |
Correct |
2 |
Incorrect |
20 ms |
14428 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
14564 KB |
Correct |
2 |
Correct |
310 ms |
15472 KB |
Correct |
3 |
Correct |
126 ms |
15192 KB |
Correct |
4 |
Correct |
131 ms |
15328 KB |
Correct |
5 |
Correct |
25 ms |
15448 KB |
Correct |
6 |
Correct |
36 ms |
15696 KB |
Correct |
7 |
Correct |
90 ms |
15348 KB |
Correct |
8 |
Correct |
242 ms |
15440 KB |
Correct |
9 |
Correct |
40 ms |
15444 KB |
Correct |
10 |
Correct |
59 ms |
15444 KB |
Correct |
11 |
Correct |
28 ms |
15440 KB |
Correct |
12 |
Correct |
546 ms |
15836 KB |
Correct |
13 |
Correct |
26 ms |
15704 KB |
Correct |
14 |
Correct |
26 ms |
15696 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
14564 KB |
Correct |
2 |
Correct |
310 ms |
15472 KB |
Correct |
3 |
Correct |
126 ms |
15192 KB |
Correct |
4 |
Correct |
131 ms |
15328 KB |
Correct |
5 |
Correct |
25 ms |
15448 KB |
Correct |
6 |
Correct |
36 ms |
15696 KB |
Correct |
7 |
Correct |
90 ms |
15348 KB |
Correct |
8 |
Correct |
242 ms |
15440 KB |
Correct |
9 |
Correct |
40 ms |
15444 KB |
Correct |
10 |
Correct |
59 ms |
15444 KB |
Correct |
11 |
Correct |
28 ms |
15440 KB |
Correct |
12 |
Correct |
546 ms |
15836 KB |
Correct |
13 |
Correct |
26 ms |
15704 KB |
Correct |
14 |
Correct |
26 ms |
15696 KB |
Correct |
15 |
Correct |
20 ms |
14424 KB |
Correct |
16 |
Correct |
317 ms |
15188 KB |
Correct |
17 |
Correct |
128 ms |
15180 KB |
Correct |
18 |
Correct |
139 ms |
15444 KB |
Correct |
19 |
Correct |
25 ms |
15192 KB |
Correct |
20 |
Correct |
35 ms |
15700 KB |
Correct |
21 |
Correct |
88 ms |
15440 KB |
Correct |
22 |
Correct |
247 ms |
15576 KB |
Correct |
23 |
Correct |
42 ms |
15420 KB |
Correct |
24 |
Correct |
56 ms |
15308 KB |
Correct |
25 |
Correct |
29 ms |
15444 KB |
Correct |
26 |
Correct |
570 ms |
15672 KB |
Correct |
27 |
Correct |
26 ms |
15700 KB |
Correct |
28 |
Correct |
24 ms |
15708 KB |
Correct |
29 |
Incorrect |
345 ms |
15196 KB |
Unexpected end of file - int32 expected |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
14564 KB |
Correct |
2 |
Correct |
310 ms |
15472 KB |
Correct |
3 |
Correct |
126 ms |
15192 KB |
Correct |
4 |
Correct |
131 ms |
15328 KB |
Correct |
5 |
Correct |
25 ms |
15448 KB |
Correct |
6 |
Correct |
36 ms |
15696 KB |
Correct |
7 |
Correct |
90 ms |
15348 KB |
Correct |
8 |
Correct |
242 ms |
15440 KB |
Correct |
9 |
Correct |
40 ms |
15444 KB |
Correct |
10 |
Correct |
59 ms |
15444 KB |
Correct |
11 |
Correct |
28 ms |
15440 KB |
Correct |
12 |
Correct |
546 ms |
15836 KB |
Correct |
13 |
Correct |
26 ms |
15704 KB |
Correct |
14 |
Correct |
26 ms |
15696 KB |
Correct |
15 |
Correct |
20 ms |
14424 KB |
Correct |
16 |
Correct |
317 ms |
15188 KB |
Correct |
17 |
Correct |
128 ms |
15180 KB |
Correct |
18 |
Correct |
139 ms |
15444 KB |
Correct |
19 |
Correct |
25 ms |
15192 KB |
Correct |
20 |
Correct |
35 ms |
15700 KB |
Correct |
21 |
Correct |
88 ms |
15440 KB |
Correct |
22 |
Correct |
247 ms |
15576 KB |
Correct |
23 |
Correct |
42 ms |
15420 KB |
Correct |
24 |
Correct |
56 ms |
15308 KB |
Correct |
25 |
Correct |
29 ms |
15444 KB |
Correct |
26 |
Correct |
570 ms |
15672 KB |
Correct |
27 |
Correct |
26 ms |
15700 KB |
Correct |
28 |
Correct |
24 ms |
15708 KB |
Correct |
29 |
Incorrect |
345 ms |
15196 KB |
Unexpected end of file - int32 expected |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
895 ms |
33204 KB |
Correct |
2 |
Correct |
1106 ms |
35008 KB |
Correct |
3 |
Correct |
1083 ms |
31156 KB |
Correct |
4 |
Correct |
521 ms |
28828 KB |
Correct |
5 |
Correct |
1238 ms |
38076 KB |
Correct |
6 |
Correct |
852 ms |
36604 KB |
Correct |
7 |
Correct |
697 ms |
30148 KB |
Correct |
8 |
Execution timed out |
2065 ms |
29676 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
895 ms |
33204 KB |
Correct |
2 |
Correct |
1106 ms |
35008 KB |
Correct |
3 |
Correct |
1083 ms |
31156 KB |
Correct |
4 |
Correct |
521 ms |
28828 KB |
Correct |
5 |
Correct |
1238 ms |
38076 KB |
Correct |
6 |
Correct |
852 ms |
36604 KB |
Correct |
7 |
Correct |
697 ms |
30148 KB |
Correct |
8 |
Execution timed out |
2065 ms |
29676 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
14648 KB |
Correct |
2 |
Correct |
20 ms |
14428 KB |
Correct |
3 |
Correct |
26 ms |
14428 KB |
Correct |
4 |
Incorrect |
20 ms |
14428 KB |
Unexpected end of file - int32 expected |
5 |
Halted |
0 ms |
0 KB |
- |