답안 #453618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
453618 2021-08-04T13:08:31 Z idas Fire drill (LMIO18_sauga) C++11
57.3002 / 100
48 ms 4984 KB
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SZ(x) ((int)((x).size()))
#define LE(vec) vec[vec.size()-1]
#define TSTS int t; cin >> t; while(t--)solve()

const int INF = 1e9;
const long long LINF = 1e18;
const long double PI = asin(1)*2;
const int MOD = 1e9+7;

using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef long long ll;
typedef long double ld;

void setIO()
{
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
 	freopen((s+".out").c_str(),"w",stdout);
}

const int N=1e3+10;
vi row, ad[N];
int lp[N];
bool v[N];

void dfs(int u)
{
    v[u]=true;
    for(auto it : ad[u]){
        if(!v[it]){
            dfs(it);
        }
    }
    row.PB(u);
}

int main()
{
    setIO();
    int t, n, s;
    cin >> t >> n >> s;
    FOR(i, 0, n)
    {
        int x;
        cin >> x;
        FOR(j, 0, x)
        {
            int b;
            cin >> b;
            ad[i].PB(b-1);
            lp[b-1]++;
        }
    }
    vector<pii> inf;
    FOR(i, 0, n)
    {
        inf.PB({lp[i], i});
    }

    sort(inf.begin(), inf.end());

    for(auto[x, y] : inf){
        if(!v[y]){
            dfs(y);
        }
    }

    for(auto b : row){
        cout << b+1 << " ";
    }
}

Compilation message

sauga.cpp: In function 'int main()':
sauga.cpp:76:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   76 |     for(auto[x, y] : inf){
      |             ^
sauga.cpp: In function 'void setIO(std::string)':
sauga.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sauga.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen((s+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 4984 KB Output is correct
2 Partially correct 1 ms 332 KB Output is partially correct
3 Partially correct 1 ms 332 KB Output is partially correct
4 Partially correct 2 ms 332 KB Output is partially correct
5 Partially correct 1 ms 352 KB Output is partially correct
6 Partially correct 1 ms 460 KB Output is partially correct
7 Partially correct 8 ms 1100 KB Output is partially correct
8 Partially correct 46 ms 4680 KB Output is partially correct
9 Partially correct 8 ms 716 KB Output is partially correct
10 Correct 1 ms 332 KB Output is correct