| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1115847 | vjudge1 | CSS (COI14_css) | C++14 | 179 ms | 7248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 5005, M = 5e6 + 5;
map<string, int> M1;
map<string, int> M2;
int tot1, tot2;
int get_name_id(string &s){
if(M1.count(s))return M1[s];
return M1[s] = ++ tot1;
}
int get_cls_id(string s){
if(M2.count(s))return M2[s];
return M2[s] = ++ tot2;
}
struct Node{
string name;
vector<int> cls;
}w[N];
int cnt;
int fa[N];
vector<int> e[N];
bitset<N> f[N];
// bool f[N][N];
vector<int> que[N];
vector<string> ans;
int szq;
int tp[N];
bool check_in(vector<int> &b, vector<int> &a){
static bool st[M] = {};
for(int u : b)st[u] = 1;
bool flg = 1;
for(int u : a)flg &= st[u];
for(int u : b)st[u] = 0;
return flg;
}
void dfs(int x){
if(f[fa[x]][szq - 1] && check_in(w[x].cls, que[szq])){
ans.push_back(w[x].name);
}
f[x][0] = 1;
for(int i = 1; i <= szq; i ++){
if(tp[i] == 0 && f[fa[x]][i])f[x][i] = 1;
else if(f[fa[x]][i - 1] && check_in(w[x].cls, que[i]))f[x][i] = 1;
}
for(int u : e[x])dfs(u);
}
char ss[N * 2], ch;
vector<int> rts;
int main(){
int n;
scanf("%d", &n);
int idnow = 0;
for(int i = 1; i <= n; i ++){
scanf(" <%c", &ch);
if(ch == '/')idnow = fa[idnow], scanf("div>");
else {
scanf("iv id='%s'", ss);
ss[strlen(ss) - 1] = '\00';
fa[++ cnt] = idnow;
idnow = cnt;
w[idnow].name = ss;
scanf(" class = \'%s", ss);
bool flg = 1;
while(flg){
int len = strlen(ss);
if(ss[len - 1] == '>')ss[len - 2] = '\00', flg = 0;
string s2 = ss;
w[idnow].cls.push_back(get_cls_id(s2));
if(flg)scanf("%s", ss);
}
}
}
for(int i = 1; i <= cnt; i ++){
if(fa[i] == 0)rts.push_back(i);
else e[fa[i]].push_back(i);
}
int m;
scanf("%d", &m);
string s;
getline(cin, s);
for(int TT = 1; TT <= m; TT ++){
stringstream SS;
getline(cin, s);
SS << s;
int tot = 0;
memset(tp, 0, sizeof(tp));
while(SS >> s){
if(s == ">")tp[tot] = 1;
else {
tot ++;
que[tot].clear();
int pos = 1;
while(pos < (int)s.size()){
auto t = s.find(".", pos);
if(t == string::npos)t = s.size();
que[tot].push_back(get_cls_id(s.substr(pos, t - pos)));
pos = t + 1;
}
}
}
ans.clear();
szq = tot;
for(int i = 0; i <= cnt; i ++)f[i].reset();
// memset(f, 0, sizeof(f));
f[0][0] = 1;
for(int u : rts)dfs(u);
cout << ans.size() << " ";
for(auto u : ans)cout << u << " ";
cout << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
