Submission #1154763

#TimeUsernameProblemLanguageResultExecution timeMemory
1154763weakweakweakVision Program (IOI19_vision)C++20
Compilation error
0 ms0 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; void construct_network(int H, int W, int K) { if ( H * W <= 900) { int id = H*W-1; vector<int > finid; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { vector<int> v1; for (int i2 = 0; i2 < H; i2++) for (int j2 = 0; j2 < W; j2++) { if (abs(i2-i) + abs(j2-j) == K) v1.push_back(i2*W+j2); } if (v1.empty()) continue; add_or(v1); id++; add_and({id, i*W+j});id++; finid.push_back(id); } } add_or(finid); return; } vector<int> prime = {2, 3, 5, 7, 17, 23, 31, 127, 391}; vector<int> chp; for (int p : prime) { if (K % p and chp.size() < 5) { chp.push_back(p); } } // 29 17 51 89 int id = H*W-1; vector<int> chpid; for (int p : chp) { vector<int> rs[400], rs2[400]; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { rs[(i+j) % p] . push_back(i*W + j); rs2[((i-j)%p+p)%p]. push_back(i*W + j); } } int r = K % p; vector<int> ids[2]; int good[2] = {0}; for (int t = 0; t < 2; t++) { for (int r1 = 0; r1 < p; r1++) { int r2 = (r1 + r) %p, r3 = 399; // if (r2 >= p) continue; if (rs[r1].empty() or (rs[r2].empty() and rs[r3].empty())) continue; auto tmp = rs[r2]; tmp.insert(tmp.end(), rs[r3].begin(), rs[r3].end()); add_or(rs[r1]); id++; add_or(tmp); id++; add_and({id-1, id});id++; ids[t].push_back(id); } for (int j = 0; j < 400; j++) rs[j] = rs2[j]; if (ids[t].empty()) continue; add_or(ids[t]); id++; good[t] = id; } if (!good[0] and !good[1]) continue; if (good[0] and good[1]) { if (K==1) add_and({good[0], good[1]}); id++; else add_or({good[0], good[1]}); id++; chpid.push_back(id); } else { // continue; int mx = max(good[0], good[1]); chpid.push_back(mx); } } // cout << id << '\n'; add_and(chpid); }

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:66:25: error: expected '}' before 'else'
   66 |                         else add_or({good[0], good[1]}); id++;
      |                         ^~~~
vision.cpp:64:42: note: to match this '{'
   64 |                 if (good[0] and good[1]) {
      |                                          ^
vision.cpp:69:17: error: 'else' without a previous 'if'
   69 |                 else {
      |                 ^~~~
vision.cpp:71:38: error: 'good' was not declared in this scope
   71 |                         int mx = max(good[0], good[1]);
      |                                      ^~~~
vision.cpp: At global scope:
vision.cpp:76:16: error: expected constructor, destructor, or type conversion before '(' token
   76 |         add_and(chpid);
      |                ^
vision.cpp:77:1: error: expected declaration before '}' token
   77 | }
      | ^