QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93980#2174. Which Planet is This?!_skb_WA 175ms20724kbC++172.8kb2023-04-04 13:30:322023-04-04 13:30:34

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-04 13:30:34]
  • 评测
  • 测评结果:WA
  • 用时:175ms
  • 内存:20724kb
  • [2023-04-04 13:30:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using i64 = long long;
using u64 = unsigned long long;

struct debug {
#define contPrint { *this << "["; \
        int f = 0; for(auto it : x) { *this << (f?", ":""); *this << it; f = 1;} \
        *this << "]"; return *this;}
 
    ~debug(){cerr << endl;}
    template<class c> debug& operator<<(c x) {cerr << x; return *this;}
    template<class c, class d>
    debug& operator<<(pair<c, d> x) {*this << "(" << x.first << ", " << x.second << ")"; 
        return *this;}
    template<class c> debug& operator<<(vector<c> x) contPrint;
#undef contPrint
};

#define dbg(x) "[" << #x << ": " << x << "]  "
#define Wa() cerr << "[LINE: " << __LINE__ << "] -> "; debug() << 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() 
{
    int n;
    scanf("%d", &n);

    auto to_int = [] (char ch[]) {
        int len = strlen(ch);
        int dot = len;
        bool neg = false;
        int start = 0;
        if(ch[0] == '-') neg = true, start = 1;
        for(int i = start; i < len; i++) {
            if(ch[i] == '.') {
                dot = i;
            }
        }

        int ret = 0;
        for(int i = start; i < dot; i++) {
            ret *= 10;
            ret += (ch[i] - '0');
        }

        string s = "";
        for(int i = dot + 1; i < len; i++) {
            s += ch[i];
        }
        while(s.length() < 4) s += '0';

        for(int i = 0; i < 4; i++) {
            ret *= 10;
            ret += (s[i] - '0');
        }
        if(neg) ret *= -1;
        return ret;
    };

    vector<pair<int, int>> fst;
    char ch1[15], ch2[16];
    for(int i = 0; i < n; i++) {
        scanf(" %s %s", ch1, ch2);
        fst.push_back({to_int(ch2), to_int(ch1)});
    }
    sort(fst.begin(), fst.end());
    vector<pair<int, int>> diff;
    for(int i = 0; i < n-1; i++) {
        diff.push_back({fst[i+1].first - fst[i].first, fst[i].second});
    }
    diff.push_back({3600000 - (fst[n-1].first - fst[0].first), fst[n-1].second});
    diff.push_back({-1e9, -1e9});

    vector<pair<int, int>> sec;
    for(int i = 0; i < n; i++) {
        scanf(" %s %s", ch1, ch2);
        sec.push_back({to_int(ch2), to_int(ch1)});
    }
    sort(sec.begin(), sec.end());
    for(int i = 0; i < n-1; i++) {
        diff.push_back({sec[i+1].first - sec[i].first, sec[i].second});
    }
    diff.push_back({3600000 - (sec[n-1].first - sec[0].first), sec[n-1].second});

    // Wa() dbg(diff);

    int len = (int)diff.size();
    vector<int> pi(len);
    for(int i = 1; i < len; i++) {
        int j = pi[i-1];
        while(j > 0 && diff[i] != diff[j]) j = pi[j-1];
        if(diff[i] == diff[j]) j++;
        pi[i] = j;
        if(pi[i] == n) {
            puts("Same");
            return 0;
        }
    }
    puts("Different");
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 3444kb

input:

3
10 0
20 40
30 -15
40 -15
20 0
30 40

output:

Different

result:

ok single line: 'Different'

Test #2:

score: -100
Wrong Answer
time: 175ms
memory: 20724kb

input:

359998
-0.0045 96.8638
-0.0045 -79.2284
-0.0045 -50.4113
-0.0045 -79.0394
-0.0045 -24.9710
-0.0045 -142.9880
-0.0045 50.6344
-0.0045 125.9464
-0.0045 -17.3039
-0.0045 42.3454
-0.0045 130.6138
-0.0045 -106.4363
-0.0045 -95.9378
-0.0045 90.7312
-0.0045 75.7615
-0.0045 -66.9785
-0.0045 -81.0752
-0.0045...

output:

Different

result:

wrong answer 1st lines differ - expected: 'Same', found: 'Different'