什么情况,3和4错了,但我自己测的的第三个题答案是对的QAQ
查看原帖
什么情况,3和4错了,但我自己测的的第三个题答案是对的QAQ
908208
waedadwawd楼主2023/2/9 08:58

#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	int n,id=1,i;
	cin >> n;
	string arr,max;
	max = "";
	for (i = 1; i <= n; i++) {
		cin >> arr;
		if (arr.size() > max.size()) {
			max = arr;
			id = i;
		}
		else if (arr.size() < max.size());
		else {
			if (arr.compare(max) == 1) {
				max = arr;
				id = i;
			}
		}
	}
	cout << id << endl;
	cout << max << endl;
}

第三个测试点数据: 7 6791385765449865851630484098561093867193 6791385765405861305476138956183659819548 6791385765448765481033867082657092835470 6791385765476183659186548165418634013875 6791385765413054861086540816508058173710 6365470813654816508136547081654108365108 36571811836547138541 正确答案: 4 6791385765476183659186548165418634013875 我的答案: 4 6791385765476183659186548165418634013875

2023/2/9 08:58
加载中...