Submission #85391

# Submission time Handle Problem Language Result Execution time Memory
85391 2018-11-19T15:18:54 Z DiegoGarcia Teoretičar (COCI18_teoreticar) C++11
0 / 130
12000 ms 45000 KB
#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

teoreticar.cpp: In function 'int main()':
teoreticar.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %lld",&l,&r,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
teoreticar.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf( "%lld %lld", &edg[i].ft, &edg[i].sd );
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 12004 ms 888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12021 ms 896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12036 ms 1344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12047 ms 1344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12012 ms 25776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12044 ms 29804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12063 ms 41128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12106 ms 44480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12026 ms 44480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12023 ms 45000 KB Time limit exceeded
2 Halted 0 ms 0 KB -