Submission #3430602


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'!'||__c>'~') __c=getc();
        while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y);
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
int a[305][305],n,m,p[305],b[305],vis[305],ans=19260817;
int main()
{
    read(n);read(m);
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) read(a[i][j]);
    for(int i=1;i<=n;i++) p[i]=1;
    while(1)
    {
        int mx=0,id=0;memset(b,0,sizeof(b));
        for(int i=1;i<=n;i++)
        {
            while(vis[a[i][p[i]]]) p[i]++;if(!a[i][p[i]]) continue;
            b[a[i][p[i]]]++;if(b[a[i][p[i]]]>mx) id=a[i][p[i]],mx=b[id];
        }
        if(!mx) break;ans=min(ans,mx);vis[id]=1;
        for(int i=1;i<=n;i++) if(a[i][p[i]]==id) p[i]++;
    }
    printf("%d\n",ans);
}

Submission Info

Submission Time
Task B - Sports Festival
User WG6101N
Language C++14 (GCC 5.4.1)
Score 700
Code Size 2852 Byte
Status AC
Exec Time 3 ms
Memory 896 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 384 KB
subtask_1_03.txt AC 1 ms 384 KB
subtask_1_04.txt AC 1 ms 384 KB
subtask_1_05.txt AC 1 ms 384 KB
subtask_1_06.txt AC 2 ms 640 KB
subtask_1_07.txt AC 2 ms 640 KB
subtask_1_08.txt AC 1 ms 640 KB
subtask_1_09.txt AC 1 ms 640 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 2 ms 384 KB
subtask_1_12.txt AC 1 ms 256 KB
subtask_1_13.txt AC 2 ms 512 KB
subtask_1_14.txt AC 3 ms 896 KB
subtask_1_15.txt AC 3 ms 896 KB
subtask_1_16.txt AC 3 ms 896 KB
subtask_1_17.txt AC 3 ms 896 KB
subtask_1_18.txt AC 3 ms 896 KB