知识点求助
  • 板块CF1692F 3SUM
  • 楼主S_zhi
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/8/24 20:51
  • 上次更新2023/11/3 01:25:24
查看原帖
知识点求助
930150
S_zhi楼主2023/8/24 20:51
#include <iostream>
#include <vector>
using namespace std ;


vector <int> q(100)  ;
vector <int> ans  ;

void work() 
{
    int n ;
    cin >> n ;
   q.clear() ; 
    ans.clear() ; 
    long long  x ;
    
    for(int i = 0 ; i < n ; i ++ )
        {
            cin >> x ; 
            x = x % 10 ; 
            q[ x ] ++ ;
        }


    for(int i = 0 ; i < 10  ; i ++ )
    {
         for(int j = 0 ; j < 10 ; j ++ )
    {
         for(int k = 0 ; k < 10 ; k ++ )
         {
            if((i + j + k) % 10 != 3)
                continue ; 
            q[i] -- , q[j] -- , q[k] -- ;
            if(q[i] < 0 || q[j] < 0 || q[k] < 0 )
            {
                q[i] ++ ; 
                q[j] ++ ;
                q[k] ++ ;
            }
            else 
            {
               
                cout << "YES" << endl ;
                return ;  
            }
        }
    }
    }
    
    cout << "NO" << endl ;
    return ; 
}
int main ()
{
    int T ;
    cin >> T ;
    while ( T -- )
    {

        work() ; 
    }
    return 0 ; 
}

这个vector 没被clear清空为什么呀

2023/8/24 20:51
加载中...