답안 #713973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713973 2023-03-23T10:55:40 Z YassineBenYounes 장난감 기차 (IOI17_train) C++17
5 / 100
11 ms 1924 KB
/*
ID: Yassine BenYounes
TASK: guard
LANG: C++
*/
#include<bits/stdc++.h>
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pbds tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;*/
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD)
ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM)
int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1};
int dy[8] = {0, 1, -1, 0, 1, -1, -1, 1};
#define endl "\n"
#define ss second
#define ff first
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd  pair<double,double>
#define vdd  vector<pdd>
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
////////////////////Only Clear Code//////////////////////////
/*
vi primes;

const int ppppp = 1e6+9;
ll mod = 1e9+7;
bool prime[ppppp];
ll fact[ppppp], invfact[ppppp];
void sieve(int n){
    memset(prime, 1, sizeof prime);
    prime[1] = 0;
    for(int i = 2; i < n;i++){
        if(!prime[i])continue;
        primes.pb(i);
        for(int j = 2*i;j < n;j+=i){
            prime[j] = 0;
        }
    }
}

vi factors(int n){
    vi res;
    for(int i = 0; i < primes.size() && primes[i]*primes[i] <= n;i++){
        if(n % primes[i] == 0)res.pb(primes[i]);
        while(n % primes[i] == 0){
            n /= primes[i];
        }
    }
    if(n > 1)res.pb(n);
    return res;
}

ll binpow(ll a, ll b){
    if(b == 0)return 1;
    ll x = binpow(a, b/2) % mod;
    ll g = x*x;
    g %= mod;
    if(b%2 == 0)return g;
    g*=a;
    g%=mod;
    return g;
}

ll modinv(ll a){
    return binpow(a, mod-2);
}

ll sub(ll a, ll b){
    ll c = (a%mod)-(b%mod);
    while(c < 0)c+=mod;
    return c;
}
ll add(ll a, ll b){
    return (((a%mod)+(b%mod)) % mod);
}

ll mult(ll a, ll b){
    a %= mod;
    b %= mod;
    ll c = a*b;
    c %= mod;
    return c;
}

ll divide(ll a, ll b){
    a %= mod;
    b = modinv(b) % mod;
    ll c = a*b;
    c%=mod;
    return c;
}

void pre_fact(int n){
    fact[0]=1;
    for(int i = 1; i < n;i++){
        fact[i] = mult(fact[i-1],i);
    }
}

void pre_invfact(int n){
    for(int i = 0; i < n;i++){
        invfact[i] = modinv(fact[i]);
    }
}

ll choose(ll k, ll n){
    ll c = mult(mult(fact[n],modinv(fact[k])), modinv(fact[n-k]));
    return c;
}

ll perm(ll n){
    return fact[n];
}

ll arrange(ll k, ll n){
    ll c = mult(fact[n],modinv(fact[n-k]));
    return c;
}
*/
void init(){
    #ifndef ONLINE_JUDGE
 
freopen("input.txt", "r", stdin);
 
freopen("output.txt", "w", stdout);
 
#endif // ONLINE_JUDGE
}

const int mx = 5005;
const int LOG = 20;
const ll inf = 1e18;
const ll mod = 1e9+7;

set<int> graph[mx];
int n, m;

vi who_wins(vi owner, vi charg, vi u, vi v){
    vi res;
    n = owner.size();
    m = u.size();
    for(int i = 0; i < m;i++){
        graph[u[i]].insert(v[i]);
    }
    for(int i = 0;i < n;i++){
        int yes = 0;
        for(int j = i;j < n;j++){
            if(!charg[j]){
                if(owner[j] == 0 && graph[j].count(j)){
                    yes = 0;
                    break;
                }
                if(graph[j].size() == 1 && graph[j].count(j)){
                    yes = 0;
                    break;
                }
            }
            else{
                if(owner[j] == 1 && graph[j].count(j)){
                    yes = 1;
                    break;
                }
                if(graph[j].size() == 1 && graph[j].count(j)){
                    yes = 1;
                    break;
                }
            }
            if(!graph[j].count(j+1))break;
        }
        res.pb(yes);
    }
    return res;
}

/*
void run_case(){
    int n, m;cin >> n >> m;
    
}
    
int main(){
    //freopen("revegetate.in", "r", stdin);
    //freopen("revegetate.out", "w", stdout);
    init();
    speed;
    //sieve(ppppp);
    //pre_fact(ppppp);
    //pre_invfact(ppppp);
    int t;
    //cin >> t;
    t=1;
    while(t--){
        run_case();
    }
}*/

/*
    NEVER GIVE UP!
    DOING SMTHNG IS BETTER THAN DOING NTHNG!!!
    Your Guide when stuck:
    - Continue keyword only after reading the whole input
    - Don't use memset with testcases
    - Check for corner cases(n=1, n=0)
    - Check where you declare n(Be careful of declaring it globally and in main)
*/

Compilation message

train.cpp: In function 'void init()':
train.cpp:138:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  138 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
train.cpp:140:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  140 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 980 KB Output is correct
2 Correct 4 ms 1188 KB Output is correct
3 Correct 5 ms 1108 KB Output is correct
4 Correct 4 ms 1108 KB Output is correct
5 Correct 4 ms 1104 KB Output is correct
6 Correct 4 ms 1092 KB Output is correct
7 Correct 6 ms 1108 KB Output is correct
8 Correct 4 ms 1108 KB Output is correct
9 Correct 4 ms 1064 KB Output is correct
10 Correct 4 ms 1108 KB Output is correct
11 Correct 5 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1876 KB Output is correct
2 Correct 10 ms 1924 KB Output is correct
3 Correct 11 ms 1876 KB Output is correct
4 Incorrect 8 ms 1876 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1492 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1876 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 980 KB Output is correct
2 Correct 4 ms 1188 KB Output is correct
3 Correct 5 ms 1108 KB Output is correct
4 Correct 4 ms 1108 KB Output is correct
5 Correct 4 ms 1104 KB Output is correct
6 Correct 4 ms 1092 KB Output is correct
7 Correct 6 ms 1108 KB Output is correct
8 Correct 4 ms 1108 KB Output is correct
9 Correct 4 ms 1064 KB Output is correct
10 Correct 4 ms 1108 KB Output is correct
11 Correct 5 ms 980 KB Output is correct
12 Incorrect 1 ms 468 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -