Submission #1201209

#TimeUsernameProblemLanguageResultExecution timeMemory
1201209ziad3ssam10A + B (IOI24_aplusb)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define endl '\n'
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define wady ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void files() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}


const int N = 1e6 + 10;
const int mod = 1e9 + 7;
pair<int, int> hsh[N], hsh_rev[N];
const int bn = 2;
int b[bn] = {37, 41};
int p[bn][N], invi[bn][N];

int add(int a, int b) { return (a + b) % mod; }

int sub(int a, int b) { return (a - b + mod) % mod; }

int mult(int a, int b) { return (1LL * a * b) % mod; }

int fp(int base, int power) {
    if (power == 0) return 1;
    int ret = fp(base, power / 2);
    ret = mult(ret, ret);
    if (power & 1) ret = mult(ret, base);
    return ret;
}

void precompute() {
    p[0][0] = p[1][0] = invi[0][0] = invi[1][0] = 1;
    int bInv[bn] = {fp(b[0], mod - 2), fp(b[1], mod - 2)};
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < bn; j++) {
            p[j][i] = mult(p[j][i - 1], b[j]);
            invi[j][i] = mult(invi[j][i - 1], bInv[j]);
        }
    }
}

pair<int, int> get_hash(char c, int idx) {
    return {mult(c - 'a' + 1, p[0][idx]), mult(c - 'a' + 1, p[1][idx])};
}

pair<int, int> query(int l, int r) {
    int hash1 = hsh[r].first, hash2 = hsh[r].second;
    if (l) {
        hash1 = mult(sub(hash1, hsh[l - 1].first), invi[0][l]);
        hash2 = mult(sub(hash2, hsh[l - 1].second), invi[1][l]);
    }
    return {hash1, hash2};
}

void build(string &s) {
    int n = s.size();
    for (int i = 1; i <= n; i++) {
        hsh[i] = get_hash(s[i - 1], i);
        if (i) {
            hsh[i].first = add(hsh[i].first, hsh[i - 1].first);
            hsh[i].second = add(hsh[i].second, hsh[i - 1].second);
        }
    }
}

void solve(int tc) {
    int a,b;cin >> a >> b;
    cout << a + b << endl;

}

signed main() {
    wady
    files();
    int tt = 1;
    //cin >> tt;
    while (tt--) solve(tt);
}#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define endl '\n'
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define wady ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void files() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}


const int N = 1e6 + 10;
const int mod = 1e9 + 7;
pair<int, int> hsh[N], hsh_rev[N];
const int bn = 2;
int b[bn] = {37, 41};
int p[bn][N], invi[bn][N];

int add(int a, int b) { return (a + b) % mod; }

int sub(int a, int b) { return (a - b + mod) % mod; }

int mult(int a, int b) { return (1LL * a * b) % mod; }

int fp(int base, int power) {
    if (power == 0) return 1;
    int ret = fp(base, power / 2);
    ret = mult(ret, ret);
    if (power & 1) ret = mult(ret, base);
    return ret;
}

void precompute() {
    p[0][0] = p[1][0] = invi[0][0] = invi[1][0] = 1;
    int bInv[bn] = {fp(b[0], mod - 2), fp(b[1], mod - 2)};
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < bn; j++) {
            p[j][i] = mult(p[j][i - 1], b[j]);
            invi[j][i] = mult(invi[j][i - 1], bInv[j]);
        }
    }
}

pair<int, int> get_hash(char c, int idx) {
    return {mult(c - 'a' + 1, p[0][idx]), mult(c - 'a' + 1, p[1][idx])};
}

pair<int, int> query(int l, int r) {
    int hash1 = hsh[r].first, hash2 = hsh[r].second;
    if (l) {
        hash1 = mult(sub(hash1, hsh[l - 1].first), invi[0][l]);
        hash2 = mult(sub(hash2, hsh[l - 1].second), invi[1][l]);
    }
    return {hash1, hash2};
}

void build(string &s) {
    int n = s.size();
    for (int i = 1; i <= n; i++) {
        hsh[i] = get_hash(s[i - 1], i);
        if (i) {
            hsh[i].first = add(hsh[i].first, hsh[i - 1].first);
            hsh[i].second = add(hsh[i].second, hsh[i - 1].second);
        }
    }
}

void solve(int tc) {
    int a,b;cin >> a >> b;
    cout << a + b << endl;

}

signed main() {
    wady
    files();
    int tt = 1;
    //cin >> tt;
    while (tt--) solve(tt);
}

Compilation message (stderr)

aplusb.cpp:91:2: error: stray '#' in program
   91 | }#pragma GCC optimize("Ofast")
      |  ^
aplusb.cpp:91:3: error: 'pragma' does not name a type; did you mean '_Pragma'?
   91 | }#pragma GCC optimize("Ofast")
      |   ^~~~~~
      |   _Pragma
aplusb.cpp:105:6: error: redefinition of 'void files()'
  105 | void files() {
      |      ^~~~~
aplusb.cpp:15:6: note: 'void files()' previously defined here
   15 | void files() {
      |      ^~~~~
aplusb.cpp:113:11: error: redefinition of 'const int N'
  113 | const int N = 1e6 + 10;
      |           ^
aplusb.cpp:23:11: note: 'const int N' previously defined here
   23 | const int N = 1e6 + 10;
      |           ^
aplusb.cpp:114:11: error: redefinition of 'const int mod'
  114 | const int mod = 1e9 + 7;
      |           ^~~
aplusb.cpp:24:11: note: 'const int mod' previously defined here
   24 | const int mod = 1e9 + 7;
      |           ^~~
aplusb.cpp:115:16: error: redefinition of 'std::pair<int, int> hsh [1000010]'
  115 | pair<int, int> hsh[N], hsh_rev[N];
      |                ^~~
aplusb.cpp:25:16: note: 'std::pair<int, int> hsh [1000010]' previously defined here
   25 | pair<int, int> hsh[N], hsh_rev[N];
      |                ^~~
aplusb.cpp:115:24: error: redefinition of 'std::pair<int, int> hsh_rev [1000010]'
  115 | pair<int, int> hsh[N], hsh_rev[N];
      |                        ^~~~~~~
aplusb.cpp:25:24: note: 'std::pair<int, int> hsh_rev [1000010]' previously defined here
   25 | pair<int, int> hsh[N], hsh_rev[N];
      |                        ^~~~~~~
aplusb.cpp:116:11: error: redefinition of 'const int bn'
  116 | const int bn = 2;
      |           ^~
aplusb.cpp:26:11: note: 'const int bn' previously defined here
   26 | const int bn = 2;
      |           ^~
aplusb.cpp:117:5: error: redefinition of 'int b [2]'
  117 | int b[bn] = {37, 41};
      |     ^
aplusb.cpp:27:5: note: 'int b [2]' previously defined here
   27 | int b[bn] = {37, 41};
      |     ^
aplusb.cpp:118:5: error: redefinition of 'int p [2][1000010]'
  118 | int p[bn][N], invi[bn][N];
      |     ^
aplusb.cpp:28:5: note: 'int p [2][1000010]' previously declared here
   28 | int p[bn][N], invi[bn][N];
      |     ^
aplusb.cpp:118:15: error: redefinition of 'int invi [2][1000010]'
  118 | int p[bn][N], invi[bn][N];
      |               ^~~~
aplusb.cpp:28:15: note: 'int invi [2][1000010]' previously declared here
   28 | int p[bn][N], invi[bn][N];
      |               ^~~~
aplusb.cpp:120:5: error: redefinition of 'int add(int, int)'
  120 | int add(int a, int b) { return (a + b) % mod; }
      |     ^~~
aplusb.cpp:30:5: note: 'int add(int, int)' previously defined here
   30 | int add(int a, int b) { return (a + b) % mod; }
      |     ^~~
aplusb.cpp:122:5: error: redefinition of 'int sub(int, int)'
  122 | int sub(int a, int b) { return (a - b + mod) % mod; }
      |     ^~~
aplusb.cpp:32:5: note: 'int sub(int, int)' previously defined here
   32 | int sub(int a, int b) { return (a - b + mod) % mod; }
      |     ^~~
aplusb.cpp:124:5: error: redefinition of 'int mult(int, int)'
  124 | int mult(int a, int b) { return (1LL * a * b) % mod; }
      |     ^~~~
aplusb.cpp:34:5: note: 'int mult(int, int)' previously defined here
   34 | int mult(int a, int b) { return (1LL * a * b) % mod; }
      |     ^~~~
aplusb.cpp:126:5: error: redefinition of 'int fp(int, int)'
  126 | int fp(int base, int power) {
      |     ^~
aplusb.cpp:36:5: note: 'int fp(int, int)' previously defined here
   36 | int fp(int base, int power) {
      |     ^~
aplusb.cpp:134:6: error: redefinition of 'void precompute()'
  134 | void precompute() {
      |      ^~~~~~~~~~
aplusb.cpp:44:6: note: 'void precompute()' previously defined here
   44 | void precompute() {
      |      ^~~~~~~~~~
aplusb.cpp:145:16: error: redefinition of 'std::pair<int, int> get_hash(char, int)'
  145 | pair<int, int> get_hash(char c, int idx) {
      |                ^~~~~~~~
aplusb.cpp:55:16: note: 'std::pair<int, int> get_hash(char, int)' previously defined here
   55 | pair<int, int> get_hash(char c, int idx) {
      |                ^~~~~~~~
aplusb.cpp:149:16: error: redefinition of 'std::pair<int, int> query(int, int)'
  149 | pair<int, int> query(int l, int r) {
      |                ^~~~~
aplusb.cpp:59:16: note: 'std::pair<int, int> query(int, int)' previously defined here
   59 | pair<int, int> query(int l, int r) {
      |                ^~~~~
aplusb.cpp:158:6: error: redefinition of 'void build(std::string&)'
  158 | void build(string &s) {
      |      ^~~~~
aplusb.cpp:68:6: note: 'void build(std::string&)' previously defined here
   68 | void build(string &s) {
      |      ^~~~~
aplusb.cpp:169:6: error: redefinition of 'void solve(int)'
  169 | void solve(int tc) {
      |      ^~~~~
aplusb.cpp:79:6: note: 'void solve(int)' previously defined here
   79 | void solve(int tc) {
      |      ^~~~~
aplusb.cpp:175:8: error: redefinition of 'int main()'
  175 | signed main() {
      |        ^~~~
aplusb.cpp:85:8: note: 'int main()' previously defined here
   85 | signed main() {
      |        ^~~~
aplusb.cpp: In function 'void files()':
aplusb.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen("in.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
aplusb.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("out.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
aplusb.cpp: In function 'void files()':
aplusb.cpp:107:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  107 |     freopen("in.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
aplusb.cpp:108:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  108 |     freopen("out.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~