답안 #291421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291421 2020-09-05T10:26:21 Z mohammad Vision Program (IOI19_vision) C++14
44 / 100
1000 ms 95824 KB
#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
 
#define endl "\n"
// #define int long long

typedef long long ll ;
const ll ooo = 1e14 ;
const ll oo = 2e9 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7  ;
const int N = 10000010  ;

map<pair<int , int> , int > mp , use;
vector<pair<int,int>> v[410] ;
int d[222][222] ;

void construct_network(int H, int W, int K) {
	vector<int> Ns , f;
	for(int i = 0 ; i < H ; ++i){
		for(int j = 0 ; j < W ; ++j){
			for(int l = 0 ; l <= K ; l++){
				int u = K - l ;
				int nx = i + l , ny = j + u ;
				int vl = i * W + j , vl1 = nx * W + ny;
				if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){
					mp[{vl , vl1}] = 1;
					mp[{vl1 , vl}] = 1;
					d[nx][ny]++;
					d[i][j]++;
				}
				nx = i - l , ny = j + u;
				vl1 = nx * W + ny;
				if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){
					mp[{vl , vl1}] = 1;
					mp[{vl1 , vl}] = 1;
					d[nx][ny]++;
					d[i][j]++;
				}
				nx = i - l , ny = j - u;
				vl1 = nx * W + ny;
				if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){
					mp[{vl , vl1}] = 1;
					mp[{vl1 , vl}] = 1;
					d[nx][ny]++;
					d[i][j]++;
				}
				nx = i + l , ny = j - u;
				vl1 = nx * W + ny;
				if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){
					mp[{vl , vl1}] = 1;
					mp[{vl1 , vl}] = 1;
					d[nx][ny]++;
					d[i][j]++;
				}
			}
		}
	}
	int mx = 0 ;
	for(int i = 0 ; i < H ; ++i)
		for(int j = 0 ; j < W ; ++j){
			v[d[i][j]].push_back({i , j});
			mx = max(mx , d[i][j]);
		}
	for(int k = mx ; k ; --k){
		while(v[k].size()){
			int i = v[k].back().first , j = v[k].back().second;
			// cout << i << ' ' << j << endl;
			v[k].erase(v[k].begin() + v[k].size() - 1);
			if(d[i][j] != k) {
				if(d[i][j] > 0) v[d[i][j]].push_back({i , j});
				continue ;
			}
			int vl = i * W + j;
			Ns.clear();
			// cout << i << ' ' << j << endl;
			for(int l = 0 ; l <= K ; l++){
				int u = K - l ;
				int nx = i + l , ny = j + u ;
				int vl1 = nx * W + ny;
				if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){
					use[{vl,vl1}] = 1;
					use[{vl1,vl}] = 1;
					if(d[i][j] <= 2){
						Ns = {vl , vl1};
						//cout << Ns[0] << ' ' << Ns[1] << endl;
						int a = add_and(Ns);
						f.push_back(a);
					}else{
						d[nx][ny]--;
						Ns.push_back(vl1);
					}
				}
				nx = i - l , ny = j + u;
				vl1 = nx * W + ny;
				if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){
					use[{vl,vl1}] = 1;
					use[{vl1,vl}] = 1;
					if(d[i][j] <= 2){
						Ns = {vl , vl1};
						//cout << Ns[0] << ' ' << Ns[1] << endl;
						int a = add_and(Ns);
						f.push_back(a);
					}else{
						d[nx][ny]--;
						Ns.push_back(vl1);
					}
				}
				nx = i - l , ny = j - u;
				vl1 = nx * W + ny;
				if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){
					use[{vl,vl1}] = 1;
					use[{vl1,vl}] = 1;
					if(d[i][j] <= 2){
						Ns = {vl , vl1};
						//cout << Ns[0] << ' ' << Ns[1] << endl;
						int a = add_and(Ns);
						f.push_back(a);
					}else{
						d[nx][ny]--;
						Ns.push_back(vl1);
					}
				}
				nx = i + l , ny = j - u;
				vl1 = nx * W + ny;
				if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){
					use[{vl,vl1}] = 1;
					use[{vl1,vl}] = 1;
					if(d[i][j] <= 2){
						Ns = {vl , vl1};
						//cout << Ns[0] << ' ' << Ns[1] << endl;
						int a = add_and(Ns);
						f.push_back(a);
					}else{
						d[nx][ny]--;
						Ns.push_back(vl1);
					}
				}
			}
			if(d[i][j] > 2){
				int a = add_or(Ns);
				Ns = {vl , a};
				a = add_and(Ns);
				f.push_back(a);
			}
			d[i][j] = 0;
		}	
	}
	//cout << f.size() << endl;
	add_or(f);
	return ;
}

// freopen("C:\\Users\\mhmdsa\\Documents\\c++\\input.txt" , "r" , stdin );
// freopen("C:\\Users\\mhmdsa\\Documents\\c++\\output.txt" , "w" , stdout );
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 27 ms 4224 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 3 ms 768 KB Output is correct
33 Correct 3 ms 896 KB Output is correct
34 Correct 28 ms 4224 KB Output is correct
35 Correct 16 ms 2944 KB Output is correct
36 Correct 3 ms 768 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 27 ms 4224 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 3 ms 768 KB Output is correct
33 Correct 3 ms 896 KB Output is correct
34 Correct 28 ms 4224 KB Output is correct
35 Correct 16 ms 2944 KB Output is correct
36 Correct 3 ms 768 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Execution timed out 1084 ms 95824 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 380 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 9 ms 2176 KB Output is correct
4 Correct 147 ms 18172 KB Output is correct
5 Correct 73 ms 10872 KB Output is correct
6 Correct 23 ms 3968 KB Output is correct
7 Correct 3 ms 416 KB Output is correct
8 Correct 21 ms 3956 KB Output is correct
9 Correct 550 ms 53968 KB Output is correct
10 Correct 256 ms 31348 KB Output is correct
11 Correct 63 ms 8952 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Incorrect 41 ms 8824 KB WA in grader: Too many instructions
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 14064 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 27 ms 4224 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 3 ms 768 KB Output is correct
33 Correct 3 ms 896 KB Output is correct
34 Correct 28 ms 4224 KB Output is correct
35 Correct 16 ms 2944 KB Output is correct
36 Correct 3 ms 768 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Execution timed out 1084 ms 95824 KB Time limit exceeded
39 Halted 0 ms 0 KB -