# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85391 | DiegoGarcia | Teoretičar (COCI18_teoreticar) | C++11 | 12106 ms | 45000 KiB |
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 <stdio.h>
#include <vector>
#define ft first
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#define sd second
#define ll long long
using namespace std;
const ll MAXM = 5e5 + 3;
const ll MAXN = 1e5 + 3;
pair <ll,ll> edg[MAXM];
ll l,r,m,minColor,buck1[MAXN],buck2[MAXN],sol[MAXM];
bool color[MAXM];
void getPerm( ll niv )
{
if( niv == m ){
/* printf("para color = %lld tenemos esto: ", minColor );
for( ll i=0; i<m; i++ ) printf("%lld ",sol[i]);
printf("\n");*/
for( ll i=1; i<=l; i++ ){
memset(color, 0, sizeof color );
for( ll j=0; j<m; j++ ){
if( edg[j].ft == i ){
if( color[sol[j]] ) return;
color[sol[j]] = true;
}
}
}
for( ll i=1; i<=r; i++ ){
memset(color, 0, sizeof color );
for( ll j=0; j<m; j++ ){
if( edg[j].sd == i ){
if( color[sol[j]] ) return;
color[sol[j]] = true;
}
}
}
printf("%lld\n", minColor);
for( ll i=0; i<m; i++ ) printf("%lld\n",sol[i]);
exit(0);
return;
}
for( ll i=1; i<=minColor; i++ )
{
sol[niv] = i;
getPerm(niv+1);
}
}
int main()
{
scanf("%lld %lld %lld",&l,&r,&m);
for( ll i=0; i<m; i++ )
{
scanf( "%lld %lld", &edg[i].ft, &edg[i].sd );
buck1[edg[i].ft]++; buck2[edg[i].sd]++;
minColor=max(minColor, max(buck1[edg[i].ft], buck2[edg[i].sd]) );
}
while( true )
{
getPerm( 0 ); //factorial, llenta todas las coloraciones posibles, empezando desde la minima requerida que es el maximo grado de un vertice
minColor++;
printf("%lld\n",minColor);
}
return 0;
}
Compilation message (stderr)
# | 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... |