답안 #863653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
863653 2023-10-20T16:35:22 Z Ahmed_Solyman Inside information (BOI21_servers) C++14
5 / 100
3500 ms 378684 KB
/*
In the name of Allah
made by: Ahmed_Solyman
*/
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"yes":"no")<<endl;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #ifndef ONLINE_JUDGE
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    #endif
    fast
    int n,q;cin>>n>>q;
    q+=n;
    q--;
    set<int>adj[n+5];
    for(int i=1;i<=n;i++)adj[i].insert(i);
    vector<int>cnt(n+5,1);
    while(q--){
        char c;cin>>c;
        if(c=='S'){
            int a,b;cin>>a>>b;
            for(int i=1;i<=n;i++){
                if(adj[b].find(i)!=adj[b].end()){
                    int u=adj[a].size();
                    adj[a].insert(i);
                    if(adj[a].size()==u+1)cnt[i]++;
                }
                if(adj[a].find(i)!=adj[a].end()){
                    int u=adj[b].size();
                    adj[b].insert(i);
                    if(adj[b].size()==u+1)cnt[i]++;
                }
            }
        }
        else if(c=='Q'){
            int a,b;cin>>a>>b;
            bool ok=adj[a].find(b)!=adj[a].end();
            person_bool(ok);
        }
        else{
            int d;cin>>d;
            cout<<cnt[d]<<endl;
        }
    }
    return 0;
}

Compilation message

servers.cpp: In function 'int main()':
servers.cpp:61:37: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |                     if(adj[a].size()==u+1)cnt[i]++;
      |                        ~~~~~~~~~~~~~^~~~~
servers.cpp:66:37: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |                     if(adj[b].size()==u+1)cnt[i]++;
      |                        ~~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1372 KB Output is correct
2 Correct 177 ms 3412 KB Output is correct
3 Correct 605 ms 48984 KB Output is correct
4 Correct 165 ms 3076 KB Output is correct
5 Correct 148 ms 2900 KB Output is correct
6 Correct 2378 ms 378684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1372 KB Output is correct
2 Correct 177 ms 3412 KB Output is correct
3 Correct 605 ms 48984 KB Output is correct
4 Correct 165 ms 3076 KB Output is correct
5 Correct 148 ms 2900 KB Output is correct
6 Correct 2378 ms 378684 KB Output is correct
7 Correct 19 ms 1368 KB Output is correct
8 Correct 169 ms 2900 KB Output is correct
9 Correct 674 ms 60780 KB Output is correct
10 Correct 182 ms 2644 KB Output is correct
11 Correct 160 ms 2388 KB Output is correct
12 Correct 2378 ms 377680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1372 KB Output is correct
2 Execution timed out 3543 ms 47944 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1372 KB Output is correct
2 Execution timed out 3543 ms 47944 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1372 KB Output is correct
2 Execution timed out 3564 ms 12972 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1372 KB Output is correct
2 Execution timed out 3564 ms 12972 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1368 KB Output is correct
2 Execution timed out 3515 ms 13272 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1368 KB Output is correct
2 Execution timed out 3515 ms 13272 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1372 KB Output is correct
2 Execution timed out 3533 ms 13224 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1372 KB Output is correct
2 Execution timed out 3533 ms 13224 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1364 KB Output is correct
2 Correct 175 ms 3528 KB Output is correct
3 Correct 595 ms 48732 KB Output is correct
4 Correct 166 ms 2876 KB Output is correct
5 Correct 154 ms 2852 KB Output is correct
6 Correct 2365 ms 378416 KB Output is correct
7 Correct 20 ms 1628 KB Output is correct
8 Execution timed out 3560 ms 50468 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1364 KB Output is correct
2 Correct 175 ms 3528 KB Output is correct
3 Correct 595 ms 48732 KB Output is correct
4 Correct 166 ms 2876 KB Output is correct
5 Correct 154 ms 2852 KB Output is correct
6 Correct 2365 ms 378416 KB Output is correct
7 Correct 20 ms 1628 KB Output is correct
8 Execution timed out 3560 ms 50468 KB Time limit exceeded
9 Halted 0 ms 0 KB -