This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
balance.cpp: In function 'int main()':
balance.cpp:43:5: warning: unused variable 'cnt' [-Wunused-variable]
43 | ll cnt = 0;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |