답안 #411389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
411389 2021-05-25T07:31:25 Z ismoilov Vision Program (IOI19_vision) C++14
10 / 100
6 ms 1224 KB
#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define int ll
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fv(a, c) for(int (a) = (1); (a) <= (c); (a)++)
#define fz(a, c) for(int (a) = (0); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define pb push_back
#define in insert
#define ss second
#define ff first
#define vi vector <int>
#define fa(a, v) for(auto (a) : (v))
#define mnel(a) *min_element(all(a))
#define mxel(a) *max_element(all(a))
#define si set<int>
#define sov(a) sort(all((a)))
void construct_network(int h, int w, int K) {
	vector<int> ss;
	if(K == 1){
		vector <vi> d(h, vector <int> (w, 0));
		fp(i,0,h){
			fp(j,0,w){
				int x = i*w+j;
				vi n;
				if(i == 0 && j == 0 ||i == 0 && j == w-1 || i == h-1 && j == 0 || i == h-1 && j == w-1){
					fpp(k,-1,1){
						int i1 = i + k, j1 = j + (abs(k) - K);
						int i2 = i + k, j2 = j - (abs(k) - K);
						if(i1 >= 0 && i1 < h && j1 >= 0 && j1 < w)
							n.pb(i1*w + j1);
						if(i2 >= 0 && i2 < h && j2 >= 0 && j2 < w)
							n.pb(i2*w + j2);
					}
					ss.pb(add_and({x, add_or(n)}));
					continue;
				}
				if(i > 0 && j > 0 && d[i][j] == 0){
					fpp(k,-1,1){
						int i1 = i + k, j1 = j + (abs(k) - K);
						int i2 = i + k, j2 = j - (abs(k) - K);
						if(i1 >= 0 && i1 < h && j1 >= 0 && j1 < w)
							n.pb(i1*w + j1), d[i1][j1] = 1;
						if(i2 >= 0 && i2 < h && j2 >= 0 && j2 < w)
							n.pb(i2*w + j2), d[i2][j2] = 1;
					}
					ss.pb(add_and({x, add_or(n)}));
				}
			}
		}
		add_or(ss);
		return;
	}
	if(max(h, w) > 10 && min(h, w) != 1){
		int i = 0, j = 0;
		int x = i*w + j;
			fpp(k,-K, K){
				int ii = i + k, jj = j + (abs(k) - K);
				if(ii >= 0 && ii < h && jj >= 0 && jj < w)
					ss.pb(add_and({x, ii*w +jj}));
				ii = i + k, jj = j - (abs(k) - K);
				if(ii >= 0 && ii < h && jj >= 0 && jj < w)
					ss.pb(add_and({x, ii*w +jj}));
		}
	}
	else{
		fp(i,0,h){
			fp(j,0,w){
				int x = i*w + j;
				fpp(k,-K, K){
					int ii = i + k, jj = j + (abs(k) - K);
					if(ii >= 0 && ii < h && jj >= 0 && jj < w)
						ss.pb(add_and({x, ii*w +jj}));
					ii = i + k, jj = j - (abs(k) - K);
					if(ii >= 0 && ii < h && jj >= 0 && jj < w)
						ss.pb(add_and({x, ii*w +jj}));
				}
			}
		}
	}
	add_or(ss);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
vision.cpp:34:3: note: in expansion of macro 'fp'
   34 |   fp(i,0,h){
      |   ^~
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
vision.cpp:35:4: note: in expansion of macro 'fp'
   35 |    fp(j,0,w){
      |    ^~
vision.cpp:38:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |     if(i == 0 && j == 0 ||i == 0 && j == w-1 || i == h-1 && j == 0 || i == h-1 && j == w-1){
      |        ~~~~~~~^~~~~~~~~
vision.cpp:38:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |     if(i == 0 && j == 0 ||i == 0 && j == w-1 || i == h-1 && j == 0 || i == h-1 && j == w-1){
      |                                                 ~~~~~~~~~^~~~~~~~~
vision.cpp:38:80: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |     if(i == 0 && j == 0 ||i == 0 && j == w-1 || i == h-1 && j == 0 || i == h-1 && j == w-1){
      |                                                                       ~~~~~~~~~^~~~~~~~~~~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
vision.cpp:39:6: note: in expansion of macro 'fpp'
   39 |      fpp(k,-1,1){
      |      ^~~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
vision.cpp:51:6: note: in expansion of macro 'fpp'
   51 |      fpp(k,-1,1){
      |      ^~~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
vision.cpp:69:4: note: in expansion of macro 'fpp'
   69 |    fpp(k,-K, K){
      |    ^~~
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
vision.cpp:79:3: note: in expansion of macro 'fp'
   79 |   fp(i,0,h){
      |   ^~
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
vision.cpp:80:4: note: in expansion of macro 'fp'
   80 |    fp(j,0,w){
      |    ^~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
vision.cpp:82:5: note: in expansion of macro 'fpp'
   82 |     fpp(k,-K, K){
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
19 Correct 1 ms 288 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
19 Correct 1 ms 288 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
19 Correct 1 ms 288 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 6 ms 840 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 288 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 288 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Incorrect 3 ms 1100 KB WA in grader: Too many instructions
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1224 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
19 Correct 1 ms 288 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
24 Halted 0 ms 0 KB -