卡时(系统时间)

· · 个人记录

会有莫名其妙的误差,不清楚原因

考试不要用这个!!

#define timer std::chrono::_V2::system_clock::time_point
class Timers
{
  public:
    timer start = chrono::high_resolution_clock::now();
    void Start()
    {
        start = chrono::high_resolution_clock::now();
    }
    //1s数据:hzoi:1450;Luogu:978
    unsigned long long GetEnd()
    {
        timer stop = chrono::high_resolution_clock::now();
        unsigned long long spend = chrono::duration_cast<std::chrono::milliseconds>(stop - start).count();
        return spend;
    }
} Timer;

signed main()
{
    Timer.Start();
    int n;
    cin >> n;
    while (Timer.GetEnd() <= 980) {}
    cout << "Hello,World!";
    return 0;
}