Submission #1176566

#TimeUsernameProblemLanguageResultExecution timeMemory
1176566TsaganaCoin Collecting (JOI19_ho_t4)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; int m[100010][3]; void solve () { cin >> n; for (i = 1; i <= 2*n; i++) { int x, y; cin >> x >> y; if (x < 1) ans += 1 - x, x = 1; else if (x > n) ans += x - n, x = n; if (y < 1) ans += 1 - y, y = 1; else if (y > 2) ans += y - 2, y = 2; m[x][y]++; } for (i = 1; i <= n; i++) { a += m[i][1] - 1, b += m[i][2] - 1; while (a > 0 && b < 0) {a--; b++; ans++;} while (a < 0 && b > 0) {a++, b--, ans++;} ans += abs(a) + abs(b); } cout << ans; } signed main() {IOS solve(); return 0;}

Compilation message (stderr)

joi2019_ho_t4.cpp: In function 'void solve()':
joi2019_ho_t4.cpp:20:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   20 |         cin >> n;
      |                ^
      |                yn
joi2019_ho_t4.cpp:21:14: error: 'i' was not declared in this scope
   21 |         for (i = 1; i <= 2*n; i++) {
      |              ^
joi2019_ho_t4.cpp:25:28: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |                 if (x < 1) ans += 1 - x, x = 1;
      |                            ^~~
      |                            abs
joi2019_ho_t4.cpp:26:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
   26 |                 else if (x > n) ans += x - n, x = n;
      |                                 ^~~
      |                                 abs
joi2019_ho_t4.cpp:28:28: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |                 if (y < 1) ans += 1 - y, y = 1;
      |                            ^~~
      |                            abs
joi2019_ho_t4.cpp:29:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |                 else if (y > 2) ans += y - 2, y = 2;
      |                                 ^~~
      |                                 abs
joi2019_ho_t4.cpp:34:14: error: 'i' was not declared in this scope
   34 |         for (i = 1; i <= n; i++) {
      |              ^
joi2019_ho_t4.cpp:35:17: error: 'a' was not declared in this scope
   35 |                 a += m[i][1] - 1, b += m[i][2] - 1;
      |                 ^
joi2019_ho_t4.cpp:35:35: error: 'b' was not declared in this scope
   35 |                 a += m[i][1] - 1, b += m[i][2] - 1;
      |                                   ^
joi2019_ho_t4.cpp:36:51: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |                 while (a > 0 && b < 0) {a--; b++; ans++;}
      |                                                   ^~~
      |                                                   abs
joi2019_ho_t4.cpp:37:51: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |                 while (a < 0 && b > 0) {a++, b--, ans++;}
      |                                                   ^~~
      |                                                   abs
joi2019_ho_t4.cpp:38:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   38 |                 ans += abs(a) + abs(b);
      |                 ^~~
      |                 abs
joi2019_ho_t4.cpp:40:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |         cout << ans;
      |                 ^~~
      |                 abs