답안 #433981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433981 2021-06-20T13:11:25 Z ismoilov 송금 (JOI19_remittance) C++14
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
void S()
{
	int n;
	cin >> n;
	vector <int> a(n);
	fp(i,0,n){
		int x, y;
		cin >> x >> y;
		a[i] = x - y;
	}
	bool yes = 0;
	fp(i,0,n){
		if(a[i]%2==1 || a[i] < 0)
			continue;
		int s = a[i];
		a[i] = 0;
		bool ok = 1;
		fp(j,0,n){
			if(a[(i+j)%n] + s < 0){
				ok = 0;
			//	cout << i << " " << j << " " << s << "\n";
				break;
			}
			s += a[(i+j)%n];
			if(s % 2 == 1){
				ok = 0;
				break;
			}
			s /= 2;
		}
		yes |= (ok && s==0);
	}
	cout << (yes ? "Yes" : "No");
}
int main()
{
	IOS;
	S();
}

Compilation message

remittance.cpp: In function 'void S()':
remittance.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
remittance.cpp:15:2: note: in expansion of macro 'fp'
   15 |  fp(i,0,n){
      |  ^~
remittance.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
remittance.cpp:21:2: note: in expansion of macro 'fp'
   21 |  fp(i,0,n){
      |  ^~
remittance.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
remittance.cpp:27:3: note: in expansion of macro 'fp'
   27 |   fp(j,0,n){
      |   ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -