QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#579721 | #9226. Game of Geniuses | guodong# | WA | 1ms | 3672kb | C++14 | 1.4kb | 2024-09-21 17:28:26 | 2024-09-21 17:28:27 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define For(x, l, r) for(int x = l; x <= r; x++)
using namespace std;
const int N = 52;
int n;
int A[N][N];
int C[N][N];
void Change(int v){
For(i,1,n){
For(j,1,n){
if(A[i][j] > v)
C[i][j] = 1;
else if(A[i][j] < v)
C[i][j] = -1;
else C[i][j]= 0;
}
}
}
int Judge(int v){
Change(v);
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++){
if(C[i][j]==0){
int flag=1;
for(int xx=1; xx<=n; xx++){
if(C[xx][j]>0||C[i][xx]<0){
flag=0;
break;
}
}
if(flag)return 1;
}
}
return 0;
}
signed main(){
#ifdef NICEGUODONG
// freopen("data.in","r",stdin);
// freopen("b.out","w",stdout);
auto start = std::chrono::high_resolution_clock::now();
#endif
cin >> n;
int minn = 1e9;
int maxx = -1;
For(i,1,n){
For(j,1,n){
cin >> A[i][j];
minn = min (minn,A[i][j]);
maxx = max (maxx,A[i][j]);
}
}
int l = minn ,r = maxx;
int ans = 0;
while(l <= r){
int mid = (l + r) >> 1;
if(Judge(mid)){
ans = mid ;
l = mid + 1;
}
else
r = mid - 1;
}
cout << ans << '\n';
#ifdef NICEGUODONG
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> duration = end - start;
std::cerr << "Runtime: " << duration.count() << " sec" << std::endl;
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
input:
3 1 4 9 8 4 2 7 5 7
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3632kb
input:
50 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2392 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 2500 25...
output:
0
result:
wrong answer 1st numbers differ - expected: '2500', found: '0'