Submission #1065198

# Submission time Handle Problem Language Result Execution time Memory
1065198 2024-08-19T03:03:39 Z pcc Soccer Stadium (IOI23_soccer) C++17
0 / 100
1 ms 348 KB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fs first
#define sc second

const int mxn = 2022;

int N;
pii rng[mxn];

vector<pii> solve(vector<int> &row){
	vector<pii> v;
	for(int i = 0;i<N;i++){
		if(!row[i]){
			if(v.empty()||v.back().sc+1 != i)v.push_back(pii(i,i));
			else v.back().sc++;
		}
	}
	return v;
}

bool check(vector<vector<int>> &F){
	for(int i = 0;i<N;i++)rng[i] = pii(-1,-1);
	for(int i = 0;i<N;i++){
		vector<pii> v;
		v = solve(F[i]);
		if(v.size()>1)return 0;
		if(v.size()==1)rng[i] = v[0];
		else rng[i] = pii(N,-1);
	}
	pii now = pii(N,N);int mx = -1;
	for(int i = 0;i<N;i++){
		if(now.fs > rng[i].fs){
			mx = i;
			now = rng[i];
		}
		else if(now.fs == rng[i].fs&&now.sc<=rng[i].sc){
			mx = i;
			now = rng[i];
		}
	}
	//for(int i = 0;i<N;i++)cerr<<rng[i].fs<<','<<rng[i].sc<<endl;
	//cerr<<"MX = "<<mx<<endl;
	for(int i = mx-1;i>=0;i--){
		pii pre = rng[i+1],now = rng[i];
		if(pre.fs == N&&now.fs != N)return false;
		if(pre.fs>now.fs||pre.sc<now.sc)return false;
	}
	for(int i = mx+1;i<N;i++){
		pii pre = rng[i-1],now = rng[i];
		if(pre.fs == N&&now.fs != N)return false;
		if(pre.fs>now.fs||pre.sc<now.sc)return false;
	}
	return true;
}

int biggest_stadium(int NN, std::vector<std::vector<int>> F){
	N = NN;
	int cnt = 0;
	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++)F[i][j],cnt += F[i][j];
	}
	if(!check(F))return false;
	cerr<<"ROW PASS!"<<endl;
	for(int i = 0;i<N;i++){
		for(int j = 0;j<i;j++)swap(F[i][j],F[j][i]);
	}
	if(!check(F))return false;
	cerr<<"COL PASS!"<<endl;
	return cnt;
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 1 ms 344 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 1 ms 344 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 1 ms 344 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 1 ms 344 KB wrong
3 Halted 0 ms 0 KB -