Submission #1204597

#TimeUsernameProblemLanguageResultExecution timeMemory
1204597tamzidMutating DNA (IOI21_dna)C++20
Compilation error
0 ms0 KiB
#include "dna.h" void init(std::string a, std::string b) { int cnt_for_a1 = count(a.begin()+x,a.begin()+y,'A'); int cnt_for_a2 = count(a.begin()+x,a.begin()+y,'T'); int cnt_for_b1 = count(b.begin()+x,b.begin()+y,'A'); int cnt_for_b2 = count(b.begin()+x,b.begin()+y,'A'); if(cnt_for_a1 != cnt_for_b1 || cnt_for_a2 != cnt) { return -1; } int cnt = 0; for(int i=x;i<y;++i) { if(a[i] != b[i]) ++cnt; } return cnt / 2; } int get_distance(int x, int y) { int n,q; cin>>n>>q; string a,b; cin>>a>>b; while(q--) { int x,y; cin>>x>>y; cout<<get_distance(a,b,x,y)<<'\n'; } return 0; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:5:42: error: 'x' was not declared in this scope
    5 |         int cnt_for_a1 = count(a.begin()+x,a.begin()+y,'A');
      |                                          ^
dna.cpp:5:54: error: 'y' was not declared in this scope
    5 |         int cnt_for_a1 = count(a.begin()+x,a.begin()+y,'A');
      |                                                      ^
dna.cpp:5:26: error: 'count' was not declared in this scope; did you mean 'std::count'?
    5 |         int cnt_for_a1 = count(a.begin()+x,a.begin()+y,'A');
      |                          ^~~~~
      |                          std::count
In file included from /usr/include/c++/11/string:52,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:4059:5: note: 'std::count' declared here
 4059 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
dna.cpp:9:54: error: 'cnt' was not declared in this scope; did you mean 'int'?
    9 |         if(cnt_for_a1 != cnt_for_b1 || cnt_for_a2 != cnt)
      |                                                      ^~~
      |                                                      int
dna.cpp:11:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   11 |                 return -1;
      |                        ^~
dna.cpp:19:20: error: return-statement with a value, in function returning 'void' [-fpermissive]
   19 |         return cnt / 2;
      |                ~~~~^~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:25:9: error: 'cin' was not declared in this scope
   25 |         cin>>n>>q;
      |         ^~~
dna.cpp:26:9: error: 'string' was not declared in this scope
   26 |         string a,b;
      |         ^~~~~~
dna.cpp:26:9: note: suggested alternatives:
In file included from /usr/include/c++/11/string:39,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/11/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/11/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
dna.cpp:27:14: error: 'a' was not declared in this scope
   27 |         cin>>a>>b;
      |              ^
dna.cpp:27:17: error: 'b' was not declared in this scope
   27 |         cin>>a>>b;
      |                 ^
dna.cpp:32:17: error: 'cout' was not declared in this scope
   32 |                 cout<<get_distance(a,b,x,y)<<'\n';
      |                 ^~~~