CSES - Datatähti 2023 alku - Results
Submission details
Task:Lehmät
Sender:Tipu
Submission time:2022-10-31 09:45:05 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:17:33: error: 'std::__cxx11::basic_string<char>::npos' cannot be used as a function
   17 |         if(s.find('*') == s.npos()){
      |                           ~~~~~~^~
input/code.cpp:12:10: warning: unused variable 'in' [-Wunused-variable]
   12 |     bool in= false;
      |          ^~

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std::chrono;
int main(){
int n, m;
cin >> n;
cin >> m;
int a = 0;
bool in= false;
for (int i = 0; i < m; i++)
{
string s;
cin >> s;
if(s.find('*') == s.npos()){
continue;
}
bool jn = false;
for (int j = 0; j < n; j++)
{
if(s[j] == '*' && jn == true){
break;
}
if(s[j] == '*' && jn == false){
jn = true;
}
if(jn){
a += s[j] == '@';
}
}
}
cout << a;
}