Submission #622516

#TimeUsernameProblemLanguageResultExecution timeMemory
622516aworueMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <dna.h> using ll = long long; //#define int ll using namespace std; #define sz(x) (int)(x).size() #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, l, r) for(int i = l; i >= r; i--) #define fi first #define se second #define mod 998244353 #define db(x) cerr << __LINE__ << " " << #x << " " << x << "\n" using vi = vector<int>; using pi = pair<int, int>; const int N = 100005; const ll inf = 1e18; int f[N][3][3]; void init(string a, string b){ auto type = [&](char c){ if(c == 'A') return 0; if(c == 'C') return 1; if(c == 'T') return 2; }; foru(i, 0, sz(a) - 1){ f[i + 1][type(a[i])][type(b[i])]++; foru(j, 0, 2) foru(k, 0, 2) f[i + 1][j][k] += f[i][j][k]; } } int get_distance(int x, int y){ int adj[3][3] = {}; int o[3] = {}, z[3] = {}; foru(i, 0, 2) foru(j, 0, 2){ adj[i][j] = f[y + 1][i][j] - f[x][i][j]; o[i] += adj[i][j]; z[j] += adj[i][j]; } } foru(i, 0, 2) if(o[i] != z[i]) return -1; int res = 0; foru(i, 0, 2) foru(j, 0, i - 1){ adj[i][j] -= min(adj[i][j], adj[j][i]); adj[j][i] -= min(adj[i][j], adj[j][i]); res += min(adj[i][j], adj[j][i]); } } int mx1 = max(adj[0][1], adj[1][0]); int mx2 = max(adj[0][2], adj[2][0]); int mx3 = max(adj[1][2], adj[2][1]); assert(mx1 == mx2 and mx2 == mx3); res += (mx1 << 1); return res; } /*void solve(){ int n, q; cin >> n >> q; string a, b; cin >> a >> b; init(a, b); while(q--){ int x, y; cin >> x >> y; cout << get_distance(x, y) << "\n"; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while(t--){ solve(); } }*/

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:45:2: warning: no return statement in function returning non-void [-Wreturn-type]
   45 |  }
      |  ^
dna.cpp: At global scope:
dna.cpp:8:23: error: expected unqualified-id before 'for'
    8 | #define foru(i, l, r) for(int i = l; i <= r; i++)
      |                       ^~~
dna.cpp:46:2: note: in expansion of macro 'foru'
   46 |  foru(i, 0, 2)
      |  ^~~~
dna.cpp:46:7: error: 'i' does not name a type
   46 |  foru(i, 0, 2)
      |       ^
dna.cpp:8:38: note: in definition of macro 'foru'
    8 | #define foru(i, l, r) for(int i = l; i <= r; i++)
      |                                      ^
dna.cpp:46:7: error: 'i' does not name a type
   46 |  foru(i, 0, 2)
      |       ^
dna.cpp:8:46: note: in definition of macro 'foru'
    8 | #define foru(i, l, r) for(int i = l; i <= r; i++)
      |                                              ^
dna.cpp:8:23: error: expected unqualified-id before 'for'
    8 | #define foru(i, l, r) for(int i = l; i <= r; i++)
      |                       ^~~
dna.cpp:49:2: note: in expansion of macro 'foru'
   49 |  foru(i, 0, 2)
      |  ^~~~
dna.cpp:49:7: error: 'i' does not name a type
   49 |  foru(i, 0, 2)
      |       ^
dna.cpp:8:38: note: in definition of macro 'foru'
    8 | #define foru(i, l, r) for(int i = l; i <= r; i++)
      |                                      ^
dna.cpp:49:7: error: 'i' does not name a type
   49 |  foru(i, 0, 2)
      |       ^
dna.cpp:8:46: note: in definition of macro 'foru'
    8 | #define foru(i, l, r) for(int i = l; i <= r; i++)
      |                                              ^
dna.cpp:50:8: error: 'j' does not name a type
   50 |   foru(j, 0, i - 1){
      |        ^
dna.cpp:8:38: note: in definition of macro 'foru'
    8 | #define foru(i, l, r) for(int i = l; i <= r; i++)
      |                                      ^
dna.cpp:50:8: error: 'j' does not name a type
   50 |   foru(j, 0, i - 1){
      |        ^
dna.cpp:8:46: note: in definition of macro 'foru'
    8 | #define foru(i, l, r) for(int i = l; i <= r; i++)
      |                                              ^
dna.cpp:55:2: error: expected declaration before '}' token
   55 |  }
      |  ^
dna.cpp:56:16: error: 'adj' was not declared in this scope
   56 |  int mx1 = max(adj[0][1], adj[1][0]);
      |                ^~~
dna.cpp:56:27: error: 'adj' was not declared in this scope
   56 |  int mx1 = max(adj[0][1], adj[1][0]);
      |                           ^~~
dna.cpp:57:16: error: 'adj' was not declared in this scope
   57 |  int mx2 = max(adj[0][2], adj[2][0]);
      |                ^~~
dna.cpp:57:27: error: 'adj' was not declared in this scope
   57 |  int mx2 = max(adj[0][2], adj[2][0]);
      |                           ^~~
dna.cpp:58:16: error: 'adj' was not declared in this scope
   58 |  int mx3 = max(adj[1][2], adj[2][1]);
      |                ^~~
dna.cpp:58:27: error: 'adj' was not declared in this scope
   58 |  int mx3 = max(adj[1][2], adj[2][1]);
      |                           ^~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from dna.cpp:1:
dna.cpp:59:2: error: expected unqualified-id before 'static_cast'
   59 |  assert(mx1 == mx2 and mx2 == mx3);
      |  ^~~~~~
dna.cpp:59:2: error: expected ')' before 'static_cast'
dna.cpp:60:2: error: 'res' does not name a type
   60 |  res += (mx1 << 1);
      |  ^~~
dna.cpp:61:2: error: expected unqualified-id before 'return'
   61 |  return res;
      |  ^~~~~~
dna.cpp:62:1: error: expected declaration before '}' token
   62 | }
      | ^
dna.cpp: In lambda function:
dna.cpp:28:2: warning: control reaches end of non-void function [-Wreturn-type]
   28 |  };
      |  ^