Submission #519325

# Submission time Handle Problem Language Result Execution time Memory
519325 2022-01-26T07:57:38 Z abcxyz Arcade (NOI20_arcade) C++14
0 / 100
432 ms 1048580 KB
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;

#define ll long long

bool isvalid(int i, int j, int n, int m){
	if(i<0||i>m-1||j<0||j>n-1){
		return false;}
	else{
		return true;}
}

void solve(){
	int n, m;
	cin>>n>>m;
	vector<pair<int,int>>a(m);
	for(int i = 0; i<m; i++){
		cin >> a[i].first;}
	for(int i = 0; i<m; i++){
		cin >> a[i].second;}
	sort(a.begin(),a.end());
	int v[m] = {0};
	int dp[m][m] = {};
	for(int i = 0; i<m; i++){
		dp[0][i] = 1;}
	bool flag= true;
	for(int i = 1; i<m; i++){
		for(int j = 0; j<m; j++){
			if(isvalid(i-1, j-1, m, m)){
				if(dp[i-1][j-1]==1){
					dp[i][j]=1;
					continue;}}
			if(isvalid(i-1, j, m, m)){
				if(dp[i-1][j]==0){
					continue;}}
			flag = true;
			for(int k = i; k>=0; k--){
				if(!flag){
					break;}
				for(int r = j; r>=0; r--){
					if(v[r]==0){
						v[r]=k;
					    break;}
					else if(abs(a[v[r]].first-a[k].first)>=abs(a[v[r]].second-a[k].second)){
						v[r]=k;
					    break;}
					else if(r==0){
						flag = false;
						break;}}}
			fill(v, v+m, 0);
			if(flag){
				dp[i][j]=1;}
		}
	}

	
    for(int j = 0; j<m; j++){
			if(dp[m-1][j]==1){
				cout<<j+1;
				break;}}
    }


int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int t;
	//cin>>t;
	t = 1;
	for(int i = 0; i<t; i++){
		solve();
	}
	return 0;
}

Compilation message

Arcade.cpp: In function 'int main()':
Arcade.cpp:68:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |  freopen("input.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Arcade.cpp:69:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |  freopen("output.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 432 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 432 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 432 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 432 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 432 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 432 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 432 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -