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>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,a[li],k,flag,t,l,r,cev[li];
string s;
map<pair<int,int>,int> mpp,mpp1;
vector<pair<int,int>> v[li];
int main(void){
scanf("%d %d %d",&l,&r,&m);
for(int i=1;i<=m;i++){
int x,y;
scanf("%d %d",&x,&y);
v[x].pb({y,i});
//~ v[y].pb({x,i});
}
int mx=0;
for(int i=1;i<=l;i++){
for(auto go:v[i]){
for(int j=1;j<=100000000;j++){
if(mpp.find({go.fi,j})==mpp.end() && mpp1.find({i,j})==mpp1.end()){
mpp[{go.fi,j}]=1;
mpp1[{i,j}]=1;
cev[go.se]=j;
mx=max(mx,j);
break;
}
}
}
}
printf("%d\n",mx);
for(int i=1;i<=m;i++)printf("%d\n",cev[i]);
return 0;
}
Compilation message (stderr)
teoreticar.cpp: In function 'int main()':
teoreticar.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%d %d %d",&l,&r,&m);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
teoreticar.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
29 | scanf("%d %d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~~
# | 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... |