제출 #476408

#제출 시각아이디문제언어결과실행 시간메모리
476408Mahmudul_KabirDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
//#include "dna.h" #include "bits/stdc++.h" #define sp <<" " #define el <<"\n" #define S second #define F first #define pb push_back #define all(ar) ar.begin(),ar.end() #define pii pair<int,int> using namespace std; using ll = long long; using ld = long double; const ll mod = 100000007; const ll si = 100005; const ll inf = 7000; ll po[si][3], pt[si][3],n; unordered_map<char,ll> hau = {{'A',0},{'T',1},{'C',2}}; ll str[si * 4]; void make(ll x,ll y,ll node,string &a,string &b){ if(x == y){ str[node] = a[x] == b[x]; return; } ll mid = x + (y - x)/2, lef = node * 2; make(x,mid,lef,a,b); make(mid+1,y,lef + 1,a,b); str[node] = str[lef] + str[lef+1]; return; } ll que(ll a,ll b,ll l,ll r,ll node){ if(b < l || r < a) return 0; if(a >= l && r >= b) return str[node]; ll mid = a + (b - a)/2, lef = node * 2; return que(a,mid,l,r,lef) + que(mid+1,b,l,r,lef+1); } void init(std::string a, std::string b){ n = a.size(); memset(po,0,sizeof(po)); memset(pt,0,sizeof(pt)); po[0][hau[a[0]]] += 1; pt[0][hau[b[0]]] += 1; for(ll i = 1; i < n; i++){ for(ll j = 0; j < 3; j++){ po[i][j] = po[i - 1][j]; pt[i][j] = pt[i - 1][j]; } po[i][hau[a[i]]] += 1; pt[i][hau[b[i]]] += 1; } memset(str,0,sizeof(str)); make(0,n-1,1,a,b); return; } ll get(ll x,ll y,ll i,bool t){ ll ans = t ? pt[y][i] : po[y][i]; if(x) ans -= t ? pt[x - 1][i] : po[x - 1][i]; return ans; } bool hobe(ll x,ll y){ //cout<<get(x,y,0,0) sp<< get(x,y,0,1) sp<<get(x,y,1,0) sp<< get(x,y,1,1) sp<<get(x,y,2,0) sp<< get(x,y,2,1) el; return (get(x,y,0,0) == get(x,y,0,1)) && (get(x,y,1,0) == get(x,y,1,1)) && (get(x,y,2,0) == get(x,y,2,1)); } int get_distance(int x, int y) { if(!hobe(x,y)) return -1; return (y - x - que(0,n - 1,x,y,1) + 2)/2; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); //* #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif //*/ ll n,q; cin>>n>>q; string a,b; cin>>a>>b; init(a,b); while(q--){ ll x,y; cin>>x>>y; cout<<get_distance(x,y) el; } return 0; }

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

dna.cpp: In function 'int main()':
dna.cpp:84:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
dna.cpp:85:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |     freopen("output.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccGQQabH.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLiJuSG.o:dna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status