Submission #1294924

#TimeUsernameProblemLanguageResultExecution timeMemory
1294924TINHexagonal Territory (APIO21_hexagon)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define FNAME "test" const int MOD = 1e9 + 7; void Task() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(FNAME".inp","r")) { freopen(FNAME".inp","r",stdin); freopen(FNAME".out","w",stdout); } } const int dx[] = {+1,+1, 0,-1,-1, 0}; const int dy[] = { 0,-1,-1, 0,+1,+1}; long long computeArea(const vector<pair<long long, long long>>& points) { long long ret = 0; int n = (int) points.size(); for (int i = 0; i < n; ++i) ret += points[i].first * points[(i + 1) % n].second; for (int i = 0; i < n; ++i) ret -= points[i].second * points[(i + 1) % n].first; ret /= 2; return abs(ret); } void Solve() { int N; cin >> N; vector<pair<long long, long long>> points; points.push_back({0, 0}); long long B = 0; for (int i = 1; i <= N; ++i) { int dir; cin >> dir; --dir; long long step; cin >> step; long long nx = points.back().first + step * dx[dir]; long long ny = points.back().second + step * dy[dir]; B += step; points.push_back({nx, ny}); } long long S = computeArea(points); // I = S - B / 2 + 1 long long ans = S - B / 2 + 1; ans %= MOD; ans = (ans + B) % MOD; cout << ans; } int main(void) { Task(); Solve(); return 2801^2801; }

Compilation message (stderr)

hexagon.cpp: In function 'void Task()':
hexagon.cpp:13:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |                 freopen(FNAME".inp","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
hexagon.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |                 freopen(FNAME".out","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccs3rwxZ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctDIAD8.o:hexagon.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccs3rwxZ.o: in function `main':
grader.cpp:(.text.startup+0x220): undefined reference to `draw_territory(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status