QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#873102#8031. GitignoreluqyouCompile Error//C++142.2kb2025-01-26 09:18:562025-01-26 09:19:03

Judging History

你现在查看的是最新测评结果

  • [2025-01-26 09:19:03]
  • 评测
  • [2025-01-26 09:18:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define sc second
#define pii pair<int,int>
#define pb push_back
#define umap unordered_map
#define mset multiset
#define pq priority_queue
#define ull unsigned long long
#define i128 __int128
const int maxn=1000+10;
int n,m,res,cnt,vis[maxn],fl[maxn];
vector<int> g[maxn];
map<string,int> mp;
int id(string str){
    // cout<<str<<" "<<dep<<endl;
    if(!mp[str]) mp[str]=++cnt;
    return mp[str];
}
void dfs(int u){
    bool fl=1;
    for(int v:g[u]) fl=0,dfs(v);
    if(fl) return ;
    for(int v:g[u]) if(vis[v]==-1) return vis[u]=-1,void();
    vis[u]=1;
}
void Dfs(int u){
    if(fl[u]) return ;
    if(vis[u]==1&&u!=1) return fl[u]=1,res++,void();
    for(int v:g[u]) Dfs(v);
}
void solve(){
    cin>>n>>m,cnt=1,res=0,mp.clear();
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        string t,lst="-";
        for(char c:s){
            if(c=='/'){
                if(lst!="-") g[id(lst)].pb(id(t));
                else g[1].pb(id(t));
                // cout<<lst<<" "<<t<<endl;
                // cout<<id(t)<<endl;
                lst=t;
            }
            t+=c;
        }
        if(lst!="-") g[id(lst)].pb(id(t));
        else g[1].pb(id(t));
        // cout<<lst<<" "<<t<<endl;
        vis[id(t)]=1;
    }
    for(int i=1;i<=m;i++){
        string s;
        cin>>s;
        string t,lst="-";
        for(char c:s){
            if(c=='/'){
                dep++;
                if(lst!="-") g[id(lst)].pb(id(t));
                else g[1].pb(id(t));
                lst=t;
            }
            t+=c;
        }
        if(lst!="-") g[id(lst)].pb(id(t));
        else g[1].pb(id(t));
        // cout<<t<<endl;
        vis[id(t)]=-1;
    }
    dfs(1),Dfs(1);
    // for(int i=1;i<=cnt;i++) cout<<vis[i]<<" ";
    // cout<<endl;
    cout<<res<<endl;
    for(int i=1;i<=cnt;i++) vis[i]=fl[i]=0,g[i].clear();
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}
/*
Samples
input:

output:

THINGS TODO:
检查freopen,尤其是后缀名
检查空间
检查调试语句是否全部注释
*/

详细

answer.code: In function ‘void solve()’:
answer.code:60:17: error: ‘dep’ was not declared in this scope; did you mean ‘dup’?
   60 |                 dep++;
      |                 ^~~
      |                 dup