Submission #643786

#TimeUsernameProblemLanguageResultExecution timeMemory
643786ymmVision Program (IOI19_vision)C++17
44 / 100
17 ms5332 KiB
#include "vision.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 4010;
int h, w, k;
int n;

int get_n(int x, int y) { return 0 <= x && x < h && 0 <= y && y < w? x*w + y: -1;}
vector<int> nbr[N];

void construct_network(int H, int W, int K)
{
	h = H; w = W; k = K;
	n = w*h;
	Loop (i,0,h) Loop (j,0,w) {
		Loop (c,0,k) {
			int x, y;

			x = i+k; y = j;
			x -= c; y += c;
			if (get_n(x, y) >= 0)
				nbr[get_n(i, j)].push_back(get_n(x, y));

			x = i; y = j+k;
			x -= c; y -= c;
			if (get_n(x, y) >= 0)
				nbr[get_n(i, j)].push_back(get_n(x, y));

			x = i-k; y = j;
			x += c; y -= c;
			if (get_n(x, y) >= 0)
				nbr[get_n(i, j)].push_back(get_n(x, y));

			x = i; y = j-k;
			x += c; y += c;
			if (get_n(x, y) >= 0)
				nbr[get_n(i, j)].push_back(get_n(x, y));
		}
	}
	//Loop (i,0,n) {
	//	cout << i << ": ";
	//	for (int x : nbr[i])
	//		cout << x << ' ';
	//	cout << '\n';
	//}
	Loop (i,0,n)
		nbr[i].size()? add_or(nbr[i]): add_not(i);
	Loop (i,0,n)
		add_and({i, n+i});
	vector<int> kooft(n);
	iota(kooft.begin(), kooft.end(), 2*n);
	add_or(kooft);
}

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:55:12: warning: narrowing conversion of 'i' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   55 |   add_and({i, n+i});
      |            ^
vision.cpp:55:12: warning: narrowing conversion of 'i' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
vision.cpp:55:16: warning: narrowing conversion of '(((ll)n) + i)' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   55 |   add_and({i, n+i});
      |               ~^~
vision.cpp:55:16: warning: narrowing conversion of '(((ll)n) + i)' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...