제출 #1117965

#제출 시각아이디문제언어결과실행 시간메모리
1117965JanPhamDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define TranLeThanhTam "TranLeThanhTam" #define all(v) v.begin(),v.end() #define reset(a,i) memset(a,i,sizeof(a)) #define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i,a,b) for (int i = (a), _b = (b); i >= _b; --i) #define compact(v) sort(all(v)), v.erase(unique(all(v)), end(v)) #define sz(v) (int) v.size() #define MASK(i) (1LL << (i) #define BIT(i,x) ((x & MASK(i)) >> (i)) typedef long long ll; typedef long double lb; typedef pair<ll,ll> pll; typedef pair<int,int> pii; const int Thanh_Tam = 1e5 + 17; const int inf = 1e9 + 17; const long long infll = 1e18 + 17; const int MOD = 1e9 + 7; const int Log = 18; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, 1, 0, -1}; const int max_block_size = 270; const ll P = 311; const int maxA = 1e2 + 17; const int addi = 1e9; const char dir[4] = {'W', 'S', 'N', 'E'}; const int Mod[3] = {998244353, MOD, 759186269}; ll mul(ll a, ll b, ll mod); ll binpow(ll a, ll b, ll mod) { ll res = 1; while (b > 0) { if (b & 1) res = mul(res,a,mod); b >>= 1; a = mul(a,a,mod); } return res; } ll add(ll a, ll b, ll mod) { return (a + b) % mod; } ll sub(ll a, ll b, ll mod) { return (a - b + mod) % mod; } ll mul(ll a, ll b, ll mod) { return ((a % mod) * (b % mod)) % mod; } ll div(ll a, ll b, ll mod) { return mul(a, binpow(b, mod - 2, mod), mod); } mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rand_range(ll l, ll r) { return uniform_int_distribution<ll>(l,r)(rng); } struct iii { int x,y,z; }; int n,q; string a,b; int pref_valid[Thanh_Tam][3][2], pref[Thanh_Tam][6]; iii per[2] = {{0, 4, 3}, {2, 5, 1}}; bool Valid(int x, int y) { int A[3], B[3]; FOR(j,0,2) { A[j] = pref_valid[y][j][0] - pref_valid[x - 1][j][0]; B[j] = pref_valid[y][j][1] - pref_valid[x - 1][j][1]; } return (A[0] == B[0] && A[1] == B[1] && A[2] == B[2]); } void ThanhTam() { int x,y; cin >> x >> y; if (!Valid(x,y)) { cout << "-1\n"; return; } int val[6]; FOR(i,0,5) val[i] = pref[y][i] - pref[x - 1][i]; int ans = 0; FOR(i,0,2) { int tmp = min(val[i * 2], val[i * 2 + 1]); val[i * 2] -= tmp; val[i * 2 + 1] -= tmp; ans += tmp; } FOR(i,0,1) { int tmp = min({val[per[i].x], val[per[i].y], val[per[i].z]}); val[per[i].x] -= tmp; val[per[i].y] -= tmp; val[per[i].z] -= tmp; ans += (tmp << 1); } FOR(i,0,5) if (val[i]) { cout << "-1\n"; return; } cout << ans << '\n'; return; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if (fopen(TranLeThanhTam".inp","r")) { freopen(TranLeThanhTam".inp","r",stdin); freopen(TranLeThanhTam".out","w",stdout); } cin >> n >> q >> a >> b; a = '.' + a; b = '.' + b; //Preparation FOR(i,1,n) { if (a[i] == 'T') a[i] = 'B'; if (b[i] == 'T') b[i] = 'B'; } FOR(i,1,n) FOR(j,0,2) { pref_valid[i][j][0] = pref_valid[i - 1][j][0] + (a[i] == char ('A' + j)); pref_valid[i][j][1] = pref_valid[i - 1][j][1] + (b[i] == char ('A' + j)); } FOR(i,1,n) { pref[i][0] = pref[i - 1][0] + (a[i] == 'A' && b[i] == 'B'); pref[i][1] = pref[i - 1][1] + (a[i] == 'B' && b[i] == 'A'); pref[i][2] = pref[i - 1][2] + (a[i] == 'A' && b[i] == 'C'); pref[i][3] = pref[i - 1][3] + (a[i] == 'C' && b[i] == 'A'); pref[i][4] = pref[i - 1][4] + (a[i] == 'B' && b[i] == 'C'); pref[i][5] = pref[i - 1][5] + (a[i] == 'C' && b[i] == 'B'); } //Processing while (q--) ThanhTam(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

dna.cpp: In function 'int main()':
dna.cpp:127:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  127 |         freopen(TranLeThanhTam".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dna.cpp:128:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  128 |         freopen(TranLeThanhTam".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc8Uv5se.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccSBUj1c.o:dna.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc8Uv5se.o: in function `main':
grader.cpp:(.text.startup+0x366): undefined reference to `init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x39d): undefined reference to `get_distance(int, int)'
collect2: error: ld returned 1 exit status