QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#309588#8031. GitignoreEbiarat#RE 0ms0kbC++203.0kb2024-01-20 18:46:352024-01-20 18:46:35

Judging History

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

  • [2024-01-20 18:46:35]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-01-20 18:46:35]
  • 提交

answer

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#include <queue>
#include <sstream>
#include <ctime>
#include <iterator>
#include <string.h>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <fstream>
#include <assert.h>
#include <numeric>
#include <complex>
#include <random>
#include <utility>
#define IOS ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a) - 1; i>=(b);i--)
#define rep(i,n) FOR(i,0,n)
#define PB push_back
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define VI vector<int>
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VL vector<long long >
#define FILL(a, value) memset(a, value, sizeof(a))
const int nax = (int)1e3 + 147;
 
using namespace std;
 
const int MOD = (int)1e9 + 7;
const int INF = 1e9 +47 ;
const long long LINF = (long long)1e18 + 4747;
 
typedef long long LL;

vector<int >g[nax];
int ignored[nax];
int ign_cnt[nax];
int sz[nax];
int ans[nax];
map<pair<int,int>,bool> edge;
bool is_vertex[nax];
map<string,int> known;
void dfs(int v)
{
    sz[v] = g[v].empty();
    ign_cnt[v] = ignored[v];
    for(auto to : g[v])
    {
        dfs(to);
        sz[v]+=sz[to];
        ign_cnt[v]+=ign_cnt[to];
    }
    if(ign_cnt[v] == sz[v] && v != 1)ans[v] = 1;
    else {
        for(auto to : g[v])ans[v] += ans[to];
        if(ignored[v])ans[v]++;
    }
 }
void solve()
{
    int n,m;
    cin >> n >> m;
    int id_v = 2;
    known["ROOT"] = 1;

    for(int j = 0;j <n + m ;j ++ )
    {
        string s;
        cin >> s;
        int prev = 1;

        int id = 0;
        string cur = "";

        while(true) {
           string cur = "";
            while(id < s.size() && s[id]!= '/'  )
            {
                cur+=s[id];
                id++;
            }
            if(id!=s.size())cur+='/';

            if(known.contains(cur)){
                known[cur] = id_v++;
            }
            int ver = known[cur];
            if(!edge.contains({prev,ver})){
                g[prev].push_back(ver);
                edge[{prev,ver}] = true;
            }
            if((edge.contains({prev,ver}) && !edge.contains({ver,prev})) || ((edge.contains({ver,prev}) && !edge.contains({prev,ver})))){
                throw 47;
            }

            
            if(j < n && id == s.size()){
                ignored[ver] = true;
            }
            prev = ver ;
            id++;
            if(id >=s.size())break;
        }
    }
    dfs(1);
    cout << ans[1] << '\n';
    for(int i =0 ; i < 1010;i++)
    {
        g[i].clear();
        ignored[i] = 0;
        ign_cnt[i] = 0;
        sz[i] = 0;
        ans[i] = 0;
    }
    edge.clear();
    known.clear();
}
int main() {
    IOS;
    int tt = 1;
    cin >> tt;
    while(tt--)
    {
        solve();
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

2
3 0
data/train
data/test
model
3 1
data/train
data/test
model
data/sample

output:


result: