Submission #729001

# Submission time Handle Problem Language Result Execution time Memory
729001 2023-04-23T11:43:31 Z Jean7 Inside information (BOI21_servers) C++14
5 / 100
51 ms 4428 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pob pop_back
#define pub push_back
#define lb lower_bound
#define ub upper_bound
#define low (i&(-i))
#define le (node<<1)
#define ri (node<<11)
#define mid ((l+r)>>1)
#define no void(cout<<"NO\n")
#define zer void(cout<<"0\n")
#define one void(cout<<"-1\n")
#define yes void(cout<<"YES\n")
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define mm(x,y) memset(x,y,sizeof(x))
 
using namespace std ;
 
const int L = 23 ;
const int B = 750 ;
const int T = 1e3+3 ;
const int N = 1e6+6 ;
const int M = 1e9+7 ;
const int D = 998244353 ;
const long long O = 4557430888798830399 ;
 
int n , k , in[N] ;
 
inline void solve () {
    cin >> n >> k ;
    int cnt = 0 ;
    for ( int i = 1 ; i <= n + k - 1 ; i++ ) {
        char c ; int x , y ;
        cin >> c ;
        if ( c == 'S' ) {
            cnt++ ;
            cin >> x >> y ;
            if ( !in[x] ) {
                in[x] = cnt ;
            }
            if ( !in[y] ) {
                in[y] = cnt ;
            }
        }
        else if ( c == 'Q' ) {
            cin >> x >> y ;
            if ( !in[x] || !in[y] ) {
                cout << "no\n" ;
            }
            else {
                if ( x == 1 ) {
                    cout << "yes\n" ;
                }
                else if ( in[x] >= in[y] ) {
                    cout << "yes\n" ;
                }
                else {
                    cout << "no\n" ;
                }
            }
        }
        else {
            cin >> x ;
            if ( !in[x] ) {
                cout << 1 << "\n" ;
            }
            else {
                cout << cnt - in[x] + 2 << "\n" ;
            }
        }
    }
}
 
signed main () {
    //freopen ( ".in" , "r" , stdin ) ;
    //freopen ( ".out" , "w" , stdout ) ;
    cin.tie(0) ;
    cout.tie(0) ;
    ios_base::sync_with_stdio(0) ;
    //cout << setprecision(14) << fixed ;
    int tc = 1 ;
    //cin >> tc ;
    while ( tc-- ) {
        solve() ;
    }
    return 0 ;
}
 
///  JJJJJJJ EEEEEEE  AAAAA  NN   NN 7777777
///     JJ   EE      AA   AA NNN  NN     77
///     JJ   EEEEEE  AAAAAAA NN N NN    77
///  JJ JJ   EE      AA   AA NN  NNN   77
///  JJJJJ   EEEEEEE AA   AA NN   NN  77
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 628 KB Output is correct
2 Correct 51 ms 4360 KB Output is correct
3 Correct 48 ms 4428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 628 KB Output is correct
2 Correct 51 ms 4360 KB Output is correct
3 Correct 48 ms 4428 KB Output is correct
4 Correct 18 ms 1516 KB Output is correct
5 Correct 46 ms 4420 KB Output is correct
6 Correct 37 ms 3536 KB Output is correct
7 Correct 45 ms 3776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -