警示后人。。。

某个 【】 在昨天考试时候使用了快读快些并用这代码写了 T1。WA 70 分

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
#define int long long
namespace Syxqwq {
	inline int read() {
		register int x = 0, s = 1;
		char c = getchar();
		while(c > '9' || c < '0') {
			if(c == '-') s = -1;
			c = getchar();
		}
		while(c >= '0' && c <= '9') {
			x = (x << 1) + (x << 3) + (c - '0');
			c = getchar();
		}
		return x * s;
	}
	void Write(int x) {
		if(x == '-') {
			putchar('-');
			x = -x;
		}
		if(x > 9) Write(x / 10);
		putchar(x % 10 + '0');
	}
	inline void write(int x, char c) {
		Write(x);
		putchar(c);
	}
}
using namespace Syxqwq;
priority_queue<int> que;
signed main() {
	int n, m;
    cin >>n >> m;
	for(int i = 1; i < m; ++i) {
		int x;cin >> x;
		que.push(x);
	}
	for(int i = m; i <= n; ++i){
		int x;cin >> x;
		que.push(x);
		int y = que.top();
        write(y, ' ');
		que.pop();
	}
	return 0;
}

但是把它 Write() 函数改成

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
#define int long long
namespace Syxqwq {
	inline int read() {
		register int x = 0, s = 1;
		char c = getchar();
		while(c > '9' || c < '0') {
			if(c == '-') s = -1;
			c = getchar();
		}
		while(c >= '0' && c <= '9') {
			x = (x << 1) + (x << 3) + (c - '0');
			c = getchar();
		}
		return x * s;
	}
	void Write(int x) {
		if(x < 0) {
			putchar('-');
			x = -x;
		}
		if(x > 9) Write(x / 10);
		putchar(x % 10 + '0');
	}
	inline void write(int x, char c) {
		Write(x);
		putchar(c);
	}
}
using namespace Syxqwq;
priority_queue<int> que;
signed main() {
	int n, m;
    cin >>n >> m;
	for(int i = 1; i < m; ++i) {
		int x;cin >> x;
		que.push(x);
	}
	for(int i = m; i <= n; ++i){
		int x;cin >> x;
		que.push(x);
		int y = que.top();
        write(y, ' ');
		que.pop();
	}
	return 0;
}

原因是某【】把 x < 0 写成了 x == '-',于是 T1 就飞走了

6 个赞

关键是这份错误的缺省源我用在比赛所有的题目上了。。。

5 个赞

666

5 个赞