#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <numeric>
#include <cassert>
#define endl '\n'
#define sp ' '
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
map<string,int> strtonum;
// DSU decl
int p[1000005];
int siz[1000005];
int findp(int v){
if(v==p[v]) return v;
return p[v] = findp(p[v]);
}
int lastmap = 1;
int makeset(string s){
//if(strtonum.find(s) != strtonum.end())
// return -1;
strtonum[s] = lastmap;
p[lastmap]=lastmap;
siz[lastmap] = 1;
lastmap++;
return 0;
//
}
void unite(int v,int u){
v = findp(v);
u = findp(u);
if(v==u) return;
if(siz[v]>=siz[u]){
p[u] = v;
siz[v] += siz[u];
}
else{
p[v] = u;
siz[u] += siz[v];
}
}
//END DSU decl
map<string,vector<string>> classes; // input uygunsa en son eklenecek
int main(){
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr);
string inn;
getline(std::cin,inn);
// diamond check yok
int q = stoi(inn);
while(q--){
string s;getline(std::cin,s);
//cout<<"INPUT:"<<sp<<s<<sp<<"END"<<sp;
// Split input
string def;
vector<string> inherit;
int lasti=0;
if(s[0] == ' ') lasti++;
for(int i=lasti;i<s.size();i++){
if(s[i]==' '){
def = s.substr(0,i);
lasti = i+1;
break;
}
}
for(int i=lasti;i<s.size();i++){
if(s[i]==' '){
if(s[lasti]==':' || s[lasti]==';'){lasti=i; continue;}
//cerr<<"i"<<sp<<i<<sp<<"lasti"<<sp<<lasti<<endl;
inherit.pb(s.substr(lasti+1,i-1-lasti));
lasti=i;
}
}
//END Split input
//string to int yapilacak
cerr<<def<<sp<<':'<<sp;
for(string cc : inherit) cerr<<cc<<","<<sp;
bool yalaan=false;
if(strtonum.find(def) != strtonum.end()){
cerr<<"|| def is decl"<<sp;
cout<<"greska"<<endl;
continue;
}
for(string c : inherit){
if(strtonum.find(c) == strtonum.end()){
cerr<<"|| "<<c<<sp<<"not decl"<<sp;
if(c.back()==';')cerr<<endl<<"GEBER"<<endl;
yalaan = true;
break;
}
}
if(yalaan){
cout<<"greska"<<endl;
continue;
}
// Diamond kontrolu icin burada checklemek lazim, buradan sonra def'i ekliyoruz
makeset(def);
cout<<"ok"<<endl;
}
}
Compilation message
dijament.cpp: In function 'int main()':
dijament.cpp:97:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
97 | for(int i=lasti;i<s.size();i++){
| ~^~~~~~~~~
dijament.cpp:105:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
105 | for(int i=lasti;i<s.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
50 ms |
504 KB |
Output is correct |
7 |
Correct |
35 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
50 ms |
504 KB |
Output is correct |
7 |
Correct |
35 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2033 ms |
6140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |