제출 #643596

#제출 시각아이디문제언어결과실행 시간메모리
643596ghostwriterVision Program (IOI19_vision)C++14
100 / 100
26 ms4392 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #include "grader.cpp" #endif #define ft front #define bk back #define st first #define nd second #define ins insert #define ers erase #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define bg begin #define ed end #define all(x) (x).bg(), (x).ed() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao VOI23 gold medal */ namespace subtask1235 { void construct_network(int H, int W, int K) { vi ans; FOR(i, 0, H - 1) FOR(j, 0, W - 1) { vi tmp; FOR(x, i, H - 1) FOR(y, 0, W - 1) { if (x == i && y <= j) continue; if (abs(i - x) + abs(j - y) != K) continue; int index = x * W + y; tmp.pb(index); } if (tmp.empty()) continue; int pos = add_or({tmp}); pos = add_and({i * W + j, pos}); ans.pb(pos); } add_or(ans); } } namespace solution { const int N = 605; const int D = 200; int c[N][N], d1[N], d2[N]; void construct_network(int H, int W, int K) { FOR(i, 0, H - 1) FOR(j, 0, W - 1) { if (c[i][j]) continue; vi tmp; int x = i, y = j; WHILE(x >= 0 && y >= 0) { tmp.pb(x * W + y); c[x][y] = 1; --x; --y; } x = i; y = j; ++x; ++y; WHILE(x < H && y < W) { tmp.pb(x * W + y); c[x][y] = 1; ++x; ++y; } d1[i - j + D] = add_or(tmp); } memset(c, 0, sizeof c); FOR(i, 0, H - 1) FOR(j, 0, W - 1) { if (c[i][j]) continue; vi tmp; int x = i, y = j; WHILE(x >= 0 && y < W) { tmp.pb(x * W + y); c[x][y] = 1; --x; ++y; } ++x; --y; WHILE(x < H && y >= 0) { tmp.pb(x * W + y); c[x][y] = 1; ++x; --y; } d2[i + j + D] = add_or(tmp); } vi tmp; FOR(i, 0, N - 1) { if (!d1[i]) continue; int x = i - D, pos1 = d1[i]; FOR(j, 0, i - 1) { if (!d1[j]) continue; int y = j - D, pos2 = d1[j]; if (abs(x - y) != K) continue; tmp.pb(add_and({pos1, pos2})); } } FOR(i, 0, N - 1) { if (!d2[i]) continue; int x = i - D, pos1 = d2[i]; FOR(j, 0, i - 1) { if (!d2[j]) continue; int y = j - D, pos2 = d2[j]; if (abs(x - y) != K) continue; tmp.pb(add_and({pos1, pos2})); } } int posk = add_or(tmp); if (K == W + H - 2) { add_and({posk}); return; } tmp.clear(); FOR(i, 0, N - 1) { if (!d1[i]) continue; int x = i - D, pos1 = d1[i]; vi tmp1; FOR(j, 0, i - 1) { if (!d1[j]) continue; int y = j - D, pos2 = d1[j]; if (abs(x - y) <= K) continue; tmp1.pb(pos2); } if (tmp1.empty()) continue; int pos3 = add_or(tmp1); tmp.pb(add_and({pos1, pos3})); } FOR(i, 0, N - 1) { if (!d2[i]) continue; int x = i - D, pos1 = d2[i]; vi tmp1; FOR(j, 0, i - 1) { if (!d2[j]) continue; int y = j - D, pos2 = d2[j]; if (abs(x - y) <= K) continue; tmp1.pb(pos2); } if (tmp1.empty()) continue; int pos3 = add_or(tmp1); tmp.pb(add_and({pos1, pos3})); } int posgk = add_or(tmp); posgk = add_not(posgk); add_and({posk, posgk}); } } void construct_network(int H, int W, int K) { if (max(H, W) <= 30 || min(H, W) == 1) { subtask1235::construct_network(H, W, K); return; } solution::construct_network(H, W, K); } /* 3 3 1 1 1 1 2 -1 */ /* From Benq: stuff you should look for * int overflow, array bounds * special cases (n=1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */

컴파일 시 표준 에러 (stderr) 메시지

vision.cpp: In function 'void subtask1235::construct_network(int, int, int)':
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:46:3: note: in expansion of macro 'FOR'
   46 |   FOR(i, 0, H - 1)
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:47:3: note: in expansion of macro 'FOR'
   47 |   FOR(j, 0, W - 1) {
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'x' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:49:4: note: in expansion of macro 'FOR'
   49 |    FOR(x, i, H - 1)
      |    ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'y' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:50:4: note: in expansion of macro 'FOR'
   50 |    FOR(y, 0, W - 1) {
      |    ^~~
vision.cpp: In function 'void solution::construct_network(int, int, int)':
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:69:3: note: in expansion of macro 'FOR'
   69 |   FOR(i, 0, H - 1)
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:70:3: note: in expansion of macro 'FOR'
   70 |   FOR(j, 0, W - 1) {
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:93:3: note: in expansion of macro 'FOR'
   93 |   FOR(i, 0, H - 1)
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:94:3: note: in expansion of macro 'FOR'
   94 |   FOR(j, 0, W - 1) {
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:115:3: note: in expansion of macro 'FOR'
  115 |   FOR(i, 0, N - 1) {
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:118:4: note: in expansion of macro 'FOR'
  118 |    FOR(j, 0, i - 1) {
      |    ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:125:3: note: in expansion of macro 'FOR'
  125 |   FOR(i, 0, N - 1) {
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:128:4: note: in expansion of macro 'FOR'
  128 |    FOR(j, 0, i - 1) {
      |    ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:141:3: note: in expansion of macro 'FOR'
  141 |   FOR(i, 0, N - 1) {
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:145:4: note: in expansion of macro 'FOR'
  145 |    FOR(j, 0, i - 1) {
      |    ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:155:3: note: in expansion of macro 'FOR'
  155 |   FOR(i, 0, N - 1) {
      |   ^~~
vision.cpp:32:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   32 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
vision.cpp:159:4: note: in expansion of macro 'FOR'
  159 |    FOR(j, 0, i - 1) {
      |    ^~~
#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...