답안 #722776

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722776 2023-04-12T20:29:14 Z groshi Monthly railway pass (LMIO18_menesinis_bilietas) C++17
16 / 100
481 ms 62072 KB
#include<bits/stdc++.h>

using namespace std;
struct wi{
    vector<int> Q,inne;
    int odw=0,byl=0;
}*w;
set<int> secik;
int mam=1;
void reku(int x)
{
    w[x].odw=mam;
    for(int i=0;i<w[x].Q.size();i++)
    {
        int pom=w[x].Q[i];
        if(w[pom].odw)
            continue;
        reku(pom);
    }
}
int wiel=0;
void reku2(int x)
{
    w[x].byl=1;
    wiel++;
    for(int i=0;i<w[x].inne.size();i++)
        secik.insert(w[w[x].inne[i]].odw);
    for(int i=0;i<w[x].Q.size();i++)
    {
        int pom=w[x].Q[i];
        if(w[pom].byl)
            continue;
        reku2(pom);
    }
}
int32_t main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n,m,x,y;
    char co;
    cin>>n>>m;
    w=new wi[n+3];
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y>>co;
        if(co=='T')
        {
            w[x].Q.push_back(y);
            w[y].Q.push_back(x);
        }
        else{
            w[x].inne.push_back(y);
            w[y].inne.push_back(x);
        }
    }
    for(int i=1;i<=n;i++)
        if(w[i].odw)
            continue;
        else{
            reku(i);
            mam++;
        }
    int wynik=0;
    for(int i=1;i<=n;i++)
    {
        if(w[i].byl)
            continue;
        secik.clear();
        wiel=0;
        reku2(i);
        if(secik.size()==mam-1 || secik.size()==mam-2)
            wynik+=wiel;
    }
    cout<<wynik;
    return 0;
}

Compilation message

menesinis_bilietas.cpp: In function 'void reku(int)':
menesinis_bilietas.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<w[x].Q.size();i++)
      |                 ~^~~~~~~~~~~~~~
menesinis_bilietas.cpp: In function 'void reku2(int)':
menesinis_bilietas.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<w[x].inne.size();i++)
      |                 ~^~~~~~~~~~~~~~~~~
menesinis_bilietas.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<w[x].Q.size();i++)
      |                 ~^~~~~~~~~~~~~~
menesinis_bilietas.cpp: In function 'int32_t main()':
menesinis_bilietas.cpp:73:24: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |         if(secik.size()==mam-1 || secik.size()==mam-2)
      |            ~~~~~~~~~~~~^~~~~~~
menesinis_bilietas.cpp:73:47: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |         if(secik.size()==mam-1 || secik.size()==mam-2)
      |                                   ~~~~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 390 ms 43192 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 18 ms 26036 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 57 ms 5924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 26036 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 209 ms 13436 KB Output is correct
7 Correct 481 ms 62072 KB Output is correct
8 Correct 8 ms 2516 KB Output is correct
9 Correct 13 ms 2732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 4 ms 584 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 340 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 328 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 4 ms 584 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 328 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 4 ms 584 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -