Submission #1446772
Source Code Expand
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) ((x)&1)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for (int i=(a); i<=(b); i+=2*((a)<(b))-1)
#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define ____ puts("\n_______________\n\n")
#define debug(x) ____; cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fir<<" , "<<(x).sec<<" }\n"
#define debug_arr(x,n) ____; cout<<#x<<":\n"; rep(i,0,n) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define debug_set(x) ____; cout<<#x<<": \n"; rep_it(it,x) cout<<(*it)<<" "; cout<<endl
#define debug_map(x) ____; cout<<#x<<": \n"; rep_it(it,x) debug_pair(*it)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const double PI=acos(-1);
const double eps=1e-9;
int o(int x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
void file_put() {
freopen("filename.in", "r", stdin);
freopen("filename.out", "w", stdout);
}
int n,m,a[305][305],b[305][305],r[305],x,t,pos,ans=oo,p[3005];
bool check[200005];
int main() {
//file_put();
scanf("%d%d",&n,&m);
rep(i,1,n) rep(j,1,m) scanf("%d",&a[i][j]);
rep(i,1,n) rep(j,1,m) b[i][a[i][j]]=j;
rep(i,1,n) r[i]=m;
x=m-1;
while (x--) {
t=0,pos=0;
memset(p,0,sizeof(p));
rep(i,1,n) p[b[i][r[i]]]++;
rep(i,1,m)
if (p[i]>t){
t=p[i];
pos=i;
}
ans=min(ans,t);
check[pos]=true;
rep(i,1,n){
if (b[i][r[i]]==pos) r[i]--;
while (check[b[i][r[i]]]) r[i]--;
}
}
printf("%d\n",ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Sports Festival |
User |
jslijin2017 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2375 Byte |
Status |
WA |
Exec Time |
2103 ms |
Memory |
1024 KB |
Compile Error
./Main.cpp: In function ‘void file_put()’:
./Main.cpp:53:39: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen("filename.in", "r", stdin);
^
./Main.cpp:54:41: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
freopen("filename.out", "w", stdout);
^
./Main.cpp: In function ‘int main()’:
./Main.cpp:63:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.cpp:64:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,1,n) rep(j,1,m) scanf("%d",&a[i][j]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 700 |
Status |
|
|
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 |
WA |
1 ms |
256 KB |
subtask_1_01.txt |
TLE |
2103 ms |
256 KB |
subtask_1_02.txt |
AC |
1 ms |
512 KB |
subtask_1_03.txt |
WA |
2 ms |
384 KB |
subtask_1_04.txt |
WA |
2 ms |
512 KB |
subtask_1_05.txt |
AC |
1 ms |
512 KB |
subtask_1_06.txt |
AC |
4 ms |
1024 KB |
subtask_1_07.txt |
WA |
4 ms |
1024 KB |
subtask_1_08.txt |
WA |
2 ms |
1024 KB |
subtask_1_09.txt |
AC |
1 ms |
1024 KB |
subtask_1_10.txt |
AC |
2 ms |
384 KB |
subtask_1_11.txt |
WA |
3 ms |
384 KB |
subtask_1_12.txt |
AC |
2 ms |
256 KB |
subtask_1_13.txt |
AC |
4 ms |
512 KB |
subtask_1_14.txt |
AC |
10 ms |
1024 KB |
subtask_1_15.txt |
WA |
10 ms |
1024 KB |
subtask_1_16.txt |
WA |
10 ms |
1024 KB |
subtask_1_17.txt |
AC |
10 ms |
1024 KB |
subtask_1_18.txt |
AC |
10 ms |
1024 KB |